1

This may be considered an additional question to this calling function with arguments in mustache javascript

My problem is I want to go something like

{{{{display_field_name}}}}

And for display_field_name to be resolved, lets say to "description", and then

{{description}} 

is then resolved.

I can do this like this, but it's not very elegant template code.

{{#resolve}}{{display_field_name}}{{/resolve}}

Which is done by adding this 'resolve' function to the current context

        resolve:function(){
            return function(text,render){
                return render("{{" + render(text) + "}}");
            };
        },

i.e. just add that to whatever hash/object you pass to Mustache.

Is there a better way of doing this ?.

Community
  • 1
  • 1
Mark Lester
  • 363
  • 4
  • 13

0 Answers0