test
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • Mr.Cat Moderator
    #1072539

    @thesdhotel

    This is build in function of dustjs. You can access value of object by using syntax javascript.

    You can see an example about it on dustjs site.

    And we can’t use actual field name because it can’t help us to access the data of object.

    • This reply was modified 7 years ago by  Mr.Cat.

    1. 2017-11-06_110914

    Wisdom is not a product of schooling but of the lifelong attempt to acquire it.

    thesdhotel Friend
    #1072651

    Hello, I see, I made a mistake.

    However, the issue that I described does exist. If you try to use dust.js helpers (http://www.dustjs.com/guides/dust-helpers/ – they have been added to Megafilter in the 1.10 update). If you try to use dust.js helpers in your layout template override for the product-item.php, they don’t work correctly when you use them for a custom field.

    See screenshot example attached below. (I used this page to test/demo: http://www.dustjs.com/test/test.html?q=helpers)

    It works correctly when the key doesn’t have a dot (for example "name"), but when you put a key with dots (for example "attr.ct1.value"), it doesn’t work.

    Do you think this is a dust.js bug?

    • This reply was modified 7 years ago by  thesdhotel.
    • This reply was modified 7 years ago by  thesdhotel.

    1. dust-helpers-bug
    Mr.Cat Moderator
    #1072799

    @thesdhotel,

    You can try this one:

    {#attr}
        {#tag}
            {@eq key=value value="3"}
                nice
            {:else}
                wow
            {/eq}
        {/tag}
    {/attr}

    You have to access object properties step by step.

    Wisdom is not a product of schooling but of the lifelong attempt to acquire it.

    thesdhotel Friend
    #1073095

    Hey man, Just tried that but it didn’t work.

    But I don’t think it’s your fault… Why? Because I tried it with {gt} and {gte} and it works correctly (even by writing the key all at once like "attr.ct1.value"). It only doesn’t work with {eq}.

    So I think this is a Dust.js bug? When trying to access a object property inside another object, {eq} doesn’t seem to work, but the others like {gt} and {gte} etc. seem to work.

    • This reply was modified 7 years ago by  thesdhotel.
    Mr.Cat Moderator
    #1073253

    @thesdhotel,

    May be some thing is not consistent. You can report to dustjs team on github. I think you’ll get the good answer 🙂

    Wisdom is not a product of schooling but of the lifelong attempt to acquire it.

    thesdhotel Friend
    #1073356

    Or maybe not… I see that they’re very inactive…

    https://github.com/linkedin/dustjs/issues
    https://github.com/linkedin/dustjs-helpers/issues

    I’ll try 😀

    thesdhotel Friend
    #1074692

    @Mr. Cat
    We have an answer…
    https://github.com/linkedin/dustjs-helpers/issues/145

    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"}}}

    and not this:

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

    So I think it’s something we need to fix in Megafilter? Is it possible for you to fix that if the array only contains one value, then don’t show the [parenthesis]?
    If it contains multiple values then it should be an array, but if it doesn’t contain multiple values it should be a single value. Does that make sense?

    Mr.Cat Moderator
    #1074711

    @thesdhotel,

    You can use this code. It works with single value.

    {#attr}
          {#ct1}
          {#value}
              {@eq key=. value="Mick"}
                  It should be true
              {:else}
                  But it's false
              {/eq}
          {/value}
          {/ct1}
    {/attr}

    Your idea is possible, but we have to change a lot of code to check array or not. It’s gonna create unaware bugs. 🙁

    • This reply was modified 7 years ago by  Mr.Cat.
    • This reply was modified 7 years ago by  Mr.Cat.

    Wisdom is not a product of schooling but of the lifelong attempt to acquire it.

    thesdhotel Friend
    #1074724

    GENIUS!

    It works!

    Or even more simplified also works:

        {#attr.ct1.value}
                  {@eq key=. value="Mick"}
                          It should be true
                  {:else}
                      But it's false
                  {/eq}
        {/attr.ct1.value}

    Thanks, you’re the man!

    • This reply was modified 7 years ago by  thesdhotel.
Viewing 9 posts - 1 through 9 (of 9 total)

This topic contains 9 replies, has 2 voices, and was last updated by  thesdhotel 7 years ago.

The topic ‘Why do you use . (dots) in your dust.js variable keys?’ is closed to new replies.