New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logical operators templates.parse support #1065
Comments
This isn't something that is supported in handlebars but I've waiting for
|
Awesome thanks! |
Yeah lets see :) it can be done with some other engines (ironically
|
Although maybe integrating a helper system might be easier overall... hmm... (Or switch to handlebars /trollshield activate)
|
For now its okay to nest your IF statements, I'm assigning as low priority because we haven't seen a real dire need for this in core just yet. ETA post 0.4x |
haha, why do you refuse to use eval? var IFEVAL = function (expression, parseData) {
var fn;
try {
// create a new function from code
// pass the parseData so that could be the context of the function
// app, meta, foo, bar these are just example arguments
// that you can pass to every functions and use inside expressions if needed, so your expression could be something like:
// topic.title && typeof meta.config.something == \'number\' && app.yo
// yes you would need to escape quotes, well, it depends.. if single or double, but you get the gist
fn = Function.apply(parseData, ['app, meta, foo, bar', 'return ' + expression + ' ; ' ] );
} catch (e) {
fn = function(){return false;};
}
if ( fn(app, meta, foo, bar) ) {
/// .... print IF block, or revaluate
} else {
// .... print ELSE block if there is one
}
} i dont know something like that, you could also just have an EVAL helper that will just output the result of the expression, no? |
Interesting 👻 I'll have a think about that, good idea.
trying to reduce the amount of tpd* I get *trolls per day |
here's a Handlebars gist, if you ever end up switching to it :P |
@psychobunny Did you still want this in for 0.4.0? |
Yup. Helpers are in
|
Oh, we're going to use helpers instead of logical operators? I think that's |
k just merged it in, ex:
or
|
Nice work @psychobunny 👍 On Fri, Mar 28, 2014 at 4:23 PM, psychobunny notifications@github.comwrote:
|
if would be nice if you can just evaluate the expression in JS if truthy or not
<!-- IF (foo && bar) || (you && me) || okletmein -->
The text was updated successfully, but these errors were encountered: