Skip to content


Subversion checkout URL

You can clone with
Download ZIP


no value when variable undefined #7

defunctzombie opened this Issue · 8 comments

3 participants


Is there a way to use a variable with {{=my_var}} and have it not print anything when that variable in undefined?

I am trying to do something like:

And the page is showing "undefined" as the value. I would prefer to not see any text.


I do realize a custom helper tag could be used but I figured a special case for undefined might be nice.


This is now supported: {{=my_var undef=""}}

Set undef to the desired default value to be rendered when the variable is undefined...

@BorisMoore BorisMoore closed this

Would it not be useful to make it default behavior that undefined === "" ? Seeing the word undefined seems a bit out of place.


I wanted to avoid built-in defaulting to "" since that would affect perf (on the normal case where values are all defined) by adding a test for undefined in the compiled template. So I proposed an opt-in approach.

However I have now managed to create a fix which does default to "" without significant perf impact. So I have removed the "undef" feature. The 09_helper-tags.html sample shows how to create a custom tag that allows setting other default values than "".


Awesome! Yea, I was using a custom helper tag before to just check for undef. Having empty string be the default is much preferred :) Thanks for the quick response.


Great for undefined but when {{my_var}} is int 0, it displays an empty string.


@danlevan I think @BorisMoore said that he has a fix for this and it will be released soon.


Yes, that's right...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.