template-engine

Creating a custom block tag in liquid

走远了吗. 提交于 2019-12-24 14:57:00
问题 I'm trying to make a custom tag {% render-slider, ['image1.jpg', 'image2.jpg',...] %} that renders in to the following html code. <div class="slider"> <a href="#" class="unslider-arrow prev icon-chevron-with-circle-left"></a> <a href="#" class="unslider-arrow next icon-chevron-with-circle-right"></a> <ul> <% images.each do |image| %> <li style="background-image: url(<%= asset_path image %>);"> <% end %> </li> </ul> </div> This will feature be used on a blog website, so that users can use this

Dojo build requesting already inlined Dijit templates

放肆的年华 提交于 2019-12-24 10:48:28
问题 I am a developer on a large Dojo project and I am having some issues with the Google Closure compiler. We have around a hundred templates for Dijit widgets so the plan was to make the Closure compiler inline the HTML in the JavaScript file rather than require them AMD style. To achieve this I changed the "mini" parameter in /profiles/app.profile.js from true to false. When compiling, everything seems to work fine, even when running the app i have no issues but something strange happens. Even

Parse string into JSON

只谈情不闲聊 提交于 2019-12-24 07:28:41
问题 I have an array of objects $arr and an object has a property named as jsonData which contains json data in a string, how to parse that string to actual JSON object and retrieve lets say value for key name ? I tried this: #foreach ($obj in $arr) #set ($jsonData = "#evaluate(${obj.jsonData})") $jsonData.get("name") ## <-- not working #end 回答1: If anyone using velocity in AWS API Gateway ends up here, you can use AWS' $util.parseJson() to covert a string to JSON. Make sure you note if your

Formatting with mako

坚强是说给别人听的谎言 提交于 2019-12-24 03:24:24
问题 Anyone know how to format the length of a string with Mako? The equivalent of print "%20s%10s" % ("string 1", "string 2") ? 回答1: you can use python's string formatting fairly easily in mako ${"%20s%10s" % ("string 1", "string 2")} giving: >>> from mako.template import Template >>> Template('${"%20s%10s" % ("string 1", "string 2")}').render() ' string 1 string 2' 来源: https://stackoverflow.com/questions/1029965/formatting-with-mako

How an included partial insert code into parent's block?

时光总嘲笑我的痴心妄想 提交于 2019-12-24 01:45:24
问题 What I want to do is to add the scripts block in dropdown.swig added to scripts block in template.swig . My usage pattern could be wrong. I've a working code using ejs-locals template engine but I would like to switch to swig . Here's the code: <!-- template.swig, to be extended --> <body> <header> {% include "navbar.swig" %} </header> <!-- template scripts --> <script src="/scripts/jquery.min.js"></script> {% block body %}{% endblock %} <!-- child scripts --> {% block scripts %}{% endblock %

Smarty: how to cache properly?

耗尽温柔 提交于 2019-12-24 00:34:40
问题 Say I have a page that contains dynamic content (e.g. search results). What is the proper caching technique? Put nocache tags around the entire page? Put nocache tags around the segment of mark up that actually contains the dynamic data? Put nocache tags around the dynamic data? Somehow tell Smarty not to cache the dynamic data? The dynamic data is assigned as a Smarty variable (e.g. via assign ). I think I need to try to maximize caching, but am struggling a bit at what needs to be cached,

How do I get my dummy app to use the Engine's template engine?

爱⌒轻易说出口 提交于 2019-12-23 12:57:50
问题 I have a Rails Engine I'm working on and the gemspec has this: s.add_development_dependency "rspec-rails" s.add_development_dependency "combustion" s.add_development_dependency "capybara" s.add_development_dependency "factory_girl_rails" s.add_development_dependency "ffaker" s.add_development_dependency "draper" s.add_runtime_dependency "sqlite3" s.add_runtime_dependency "slim-rails" s.add_runtime_dependency "sass-rails" s.add_runtime_dependency "jquery-rails" s.add_runtime_dependency "rails"

playframework 1.2. insert raw html into template?

人盡茶涼 提交于 2019-12-23 10:50:36
问题 Assume the template consists of only one variable: ${htmlString} and the corresponding Controller: render("<div>some html markup</div>"); As a result i get an escaped string, but want to get the original html. Is there any way to do this? 回答1: You can use ${mystring.raw()} i think. Or embed it inside a #{verbatim} tag. -morten 回答2: In the Play2 template engine the escaping is done like this: @Html("\n<br>") (Source) 来源: https://stackoverflow.com/questions/7919256/playframework-1-2-insert-raw

How do I check to see if a Smarty variable is already assigned?

不羁的心 提交于 2019-12-23 08:01:12
问题 How do I check to see if a particular value has already been assigned to Smarty and if not assign a (default) value? Answer: if ($this->cismarty->get_template_vars('test') === null) { $this->cismarty->assign('test', 'Default value'); } 回答1: Smarty 2 if ($smarty->get_template_vars('foo') === null) { $smarty->assign('foo', 'some value'); } Smarty 3 if ($smarty->getTemplateVars('foo') === null) { $smarty->assign('foo', 'some value'); } Note that for Smarty 3 , you will have to use $smarty-

how to render arraylist or list and to handle it in template play framework 2.x

孤者浪人 提交于 2019-12-23 02:59:10
问题 I was familiar with Play 1.x . But I had to use cassandra DB. That is why I had to use Play 2.x However Scala mixing everything really. Template is very different in Play 2.x For example, in Play 1.x I just could send any parameter as String , int , object instance, arraylist etc. In render to the view template and could use these paramaters easly in template. I dont know how to succed this in Play 2.x there is only a render and it just enable me to render a String . I read something about