Giter Club home page Giter Club logo

Comments (7)

rashad612 avatar rashad612 commented on June 24, 2024 1

In your ctx value is an array. You're trying to compare the values between a string and an array. Your ctx should be something like this:

{"attr":{"ct1":{"value":"Mick"}}}

from dustjs-helpers.

rashad612 avatar rashad612 commented on June 24, 2024 1

@fpreti, how about this?

{#user}
{@eq key="GRUPPO" value="STEP2"}{/eq}
{/user}

from dustjs-helpers.

AndySDH avatar AndySDH commented on June 24, 2024

In your ctx value is an array. You're trying to compare the values between a string and an array.

@rashad612 Uuuuuuuh I see. Thanks for clarifying that. That makes sense.
For curiosity, is there any way to compare whether a string is contained in an array?
Thanks again!

from dustjs-helpers.

rashad612 avatar rashad612 commented on June 24, 2024

The simplest way, in JavaScript is using indexOf:

// Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
var a = [2, 9, 9]; 
a.indexOf(2); // 0 
a.indexOf(7); // -1

if (a.indexOf(7) === -1) {
  // element doesn't exist in array
}
// otherwise it exists

To have this worked in Dust, you might need to write your own Dust helper, containing the previous snippet. Please refer to AddingNewHelpers here: http://www.dustjs.com/guides/dust-helpers/

from dustjs-helpers.

fpreti avatar fpreti commented on June 24, 2024

Hi!
i have the same issue, @eq don't work properly.
In my case user.GRUPPO it's a string but {@eq key=user.GRUPPO value="STEP2"}{/eq} return false (the value of user.GRUPPO it's STEP2) :-)

thanks

from dustjs-helpers.

fpreti avatar fpreti commented on June 24, 2024

Hi, @rashad612
i think that this issue can be marked closed, i tried with your solution and works fine!

Thank you

from dustjs-helpers.

rashad612 avatar rashad612 commented on June 24, 2024

@AndySDH

from dustjs-helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.