业务场景,在线更换展示样式,如企业网站、博客、微信公众号等。
关键代码
扩展指令 stringTemplate: public class StringTemplateDirective extends Directive { private Integer id; public void exec(Env env, Scope scope, Writer writer) { this.id =(Integer)scope.get("theme"); Env envNoUse = new Env(env.getEngineConfig()); Parser parser = new Parser(envNoUse, new StringBuilder(ThemeService.me.findById(id).getContent()), null); Stat stat = parser.parse(); stat.exec(env,scope,writer); } } view.html: #@layout() #define main() #stringTemplate() #end #define css() #end