Home Problems in Markup.js accessing variable from the root when inside a loop
Reply: 0

Problems in Markup.js accessing variable from the root when inside a loop

user1781 Published in June 23, 2018, 5:29 pm

I'm using Markup.JS ( https://github.com/adammark/Markup.js ), and it works well for the most of it. The problem I'm having, is accessing a variable from the parent loop. Here is the object that gets passed to it:

The template code is:

This works here: {{perms.link_modify}}

    <td><a href="{{detailed_url}}" target="_blank">{{Title}}</a></td>
    <td>{{if URL}}
            <a href="{{URL}}" target="_blank">{{URL}}</a>
        {{if isValidated}}
            <!-- doesn't have a value here -->
            foo: {{perms.link_modify}}
            <!-- not relevent to question -->

When run, this part:

            foo: {{perms.link_modify}}

Comes up as ??? (non-recognised variable). The problem seems to be that it's not realising its meant to be coming from the root (not inside the loop itself). Is there a way to tell it to go up one level when looking? (hopefully that makes sense!)

FWIW, I'm aware I can just copy the value of "perms" into the loop values, but this means repeating the same data over and over, and seems a bit of a messy hack (especially if there are 100's of items in the loop, as perms would need to be repeated in every one)

UPDATE: I just found this post: https://github.com/adammark/Markup.js/pull/51/files?diff=split&short_path=04c6e90

I'm on version 1.5.21, so I'm trying to see how to implement it (as it's not released)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.314321 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO