GithubHelp home page GithubHelp logo

Comments (5)

nolimits4web avatar nolimits4web commented on June 16, 2024

Hi there,
It would be really hard to parse such conditions, but you can just create your custom helper, like i did for myself with if

Template7.registerHelper('if_compare', function (a, operator, b, options) {
    var match = false;
    if (
        (operator === '==' && a == b) ||
        (operator === '===' && a === b) ||
        (operator === '!=' && a != b) ||
        (operator === '>' && a > b) ||
        (operator === '<' && a < b) ||
        (operator === '>=' && a >= b) ||
        (operator === '<=' && a <= b)
        ) {
        match = true;
    }
    if (match) return options.fn(this);
    else return options.inverse(this);
});

And then use it like:

{{#if_compare a ">" b}} ... {{/if_compare}}
{{#if_compare a "===" b}} ... {{else}} ... {{/if_compare}}

So you can do the same for unless helper

from template7.

GuillaumeBiton avatar GuillaumeBiton commented on June 16, 2024

OK thanks vladimir, I will do it

from template7.

GuillaumeBiton avatar GuillaumeBiton commented on June 16, 2024

Hello again,

Sorry but It won't work :

T7.registerHelper('unmatch', function (a, b, options) {
    if (a !== b) {
        return options.fn(this, options.data);
    } else {
        return options.inverse(this, options.data);
    }
});

test is ok but nothing is hide by Template7

from template7.

GuillaumeBiton avatar GuillaumeBiton commented on June 16, 2024

Ok my bad, I wasn't closing correctly my helper in template page

from template7.

MarioVanDenEijnde avatar MarioVanDenEijnde commented on June 16, 2024

Hello Framework team,

I want to pass a json object (or json string) from page to page from inside a template
I tried the following but do not succeed:

Below we call the template and present the json object.
We also tried to stringify the json but also with no result.

Can you advise please?

}).then(function(result){
    console.log(JSON.stringify(result[0]));
    Template7.registerHelper('stringify', function (context){ return JSON.stringify(context[0]); });
    var foodsearchHTML = $('script#foodsearchresultTemplate').html();
    var compiledFoodSearchTemplate = Template7.compile(foodsearchHTML);
    foodHTML3 = compiledFoodSearchTemplate(result);
    document.getElementById('content-wrap-foodsearch').innerHTML = foodHTML3;
});

The template is as follows:

<script id="foodsearchresultTemplate" type="text/template7">
<div class="list-block media-list">
<ul>
{{#each this}}
    <li>
      <a onclick="open7consumptionNew('{{#stringify this}}');" data-context-name="object.{{this}}" class="item-content item-link">
        <!--<div class="item-media"><i class="icon icon-f7"></i></div>-->
        <div class="item-inner">
        <div class="row">
          <div class="item-title col-70" style="padding-left:10px">{{this.title}}</div>
          <div class="item-after col-30">{{this.unitNameFriendly}}</div>
        </div>
        </div>
      </a>
    </li>
{{/each}}
</ul>
</div>
</script>

from template7.

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.