scala - Handling inner tags in Mustache's TemplateFunction -


i have scala method in controller handles {{_tl2}}{{/tl2}} tags.

 def tl2 = {     new templatefunction() {       override def apply(input: string): string = {         util.getlength("tag_2", input)       }     }   } 

it works fine when mustache contains statements such {{_tl2}}hi, hello{{/i}}

however, when have tags such {{_tl2}}{{my_sentence}}{{/tl2}}, passes "{{my_sentence}}" is, without expanding it. understand need expand {{my_sentence}} in templatefunction.apply method. there way can accept sort of function in apply can use on "input"?

edit: found similar question , solution mustache.js, none java implementation. mustache doesn't evaluate {{}} inside function

the solution directly use guava's new com.google.common.base.function[string, string]() instead of templatefunction.

here's updated definition

import com.google.common.base.{function => gfunction}  def tl2 = {     new gfunction[string, string]() {       override def apply(input: string): string = {         util.getlength("tag_2", input)       }     }  } 

credit: got answer offline https://stackoverflow.com/users/2491266/sam-pullara


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -