template-engine

Jinja2 translation of links

我的未来我决定 提交于 2019-12-04 07:47:50
From a Jinja2 template, this is the rendered line I'm after (in English): This is the <a href="roadmap.html">roadmap</a> Translated in Dutch should result in: Dit is de <a href="roadmap.html">planning</a> This Jinja2 line gets me there -almost- {{ _('This is the %(roadmap)s.', roadmap='<a href="roadmap.html">roadmap</a>'|safe) }} Unfortunately, the word 'roadmap' is not translated. What would be the Jinja2 way of accomplishing this? Splitting the link in roadmap1 and roadmap2? I hope for something more clever. These should work: {{ _('This is the') }} <a href="roadmap.html">{{ _('roadmap') }}<

Can NHaml be used as a general purpose template engine? (outside of MVC)

こ雲淡風輕ζ 提交于 2019-12-04 03:56:45
问题 I've seen a lot of people that like using the NHaml View Engine in ASP.NET MVC, but I'm wondering if NHaml can be used as a general purpose templating engine in .NET ? I'd like to use NHaml from a Console application, or to generate HTML email templates, outside of the ASP MVC View Engine environment. Is this possible? I haven't found many code examples anywhere showing how to do this. Thanks! 回答1: Yes, it can be used without ASP.Net MVC. I use it for my own web server (but that doesn't mean

How to use the John Resig JavaScript Micro-Templating engine?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 03:53:28
I have searched for a bit on a basic example on using the John Resig JavaScript Micro-Templating engine on Google but came out dry. I decided to bring it to base guys. Can anyone help with a simple example on using this engine? I have never used a client side template engine before. Update: This is the complete HTML document. Thanks to Will. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>John Resig JavaScript Micro-Templating engine</title> <script src="jquery-1.3.2.js" type="text/javascript"></script> <script src="MicroTemplates.js" type="text/javascript"></script> <script type=

Generating HTML using a template from a .NET application

℡╲_俬逩灬. 提交于 2019-12-04 02:47:54
I have a .NET console application that needs to generate some HTML files. I could just construct the HTML in a StringBuilder and write the contents out to a file, but I was thinking it would be nicer to use some kind of template file with placeholders for where the data goes and then process my data through it at runtime. I'm guessing there are ways to use aspx, or T4, or some of the alternative view engines that you can use with ASP.NET MVC, but I don't know what would be easiest to integrate into a console application (or how I would go about integrating them). I want to end up able to call

Show all of data comming from mongodb and render it in doT.js templating engine

拥有回忆 提交于 2019-12-03 23:07:16
问题 I wanted to extract data from mongodb and pass it to the view. Everything seems to work, but instead of seeing all 10000 records show up I see only one. I feel that I am very close to solving it, but I got stuck... I am using node-mongodb-native, express and dot.js to achieve my goal. Here is my app.js, look for the app.get() that's where all the action is: /** * Mongo DB */ var mongodb = require('mongodb'), serverdb = new mongodb.Server('127.0.0.1', 27017, {}), dbName = new mongodb.Db('test'

Jinja2 for word templating

让人想犯罪 __ 提交于 2019-12-03 17:32:05
I would like to use jinja2 for word templating like mentioned is this short article. The problem I'm facing is as follows, if I put {{title}} in my word-file the resulting xml can look like this: <w:r><w:t>{{</w:t></w:r><w:proofErr w:type="gramStart"/><w:r><w:t>title</w:t></w:r><w:proofErr w:type="gramEnd"/><w:r><w:t>}}</w:t></w:r></w:p> so it is impossible for jinja to replace this accordingly. Is there a possibility to prevent word from splitting {{title}} in separate text elements? (if I copy from a text-editor it works fine) This is an issue that is in word, relating to the proofErr tag.

How to round a value in Twig

佐手、 提交于 2019-12-03 14:52:54
问题 I want to round a value in Twig. Example: I want to display 80.5555 as 80.55 . Can any one suggest me how to do that? 回答1: You could use the format filter for that: {{ '%.2f'|format(80.5555) }} But note that it will round it to 80.56 . 回答2: {{ 80.5555 | number_format(2) }} Here is the documentation number_format 回答3: Twig documentation says that there's a filter for this task, since 1.15.0: just write {{80.5555|round}} http://twig.sensiolabs.org/doc/filters/round.html 来源: https:/

How to implement pluralize & other extensions using Playframework 2.0

给你一囗甜甜゛ 提交于 2019-12-03 14:27:14
In playframework 1.x there used to be some bundled java extensions for the templating engine: http://www.playframework.org/documentation/1.2.3/javaextensions I'm looking for the same functionality in playframework 2.0. For example how would I do this? colour${['red', 'green', 'blue'].pluralize()} I am doing this malually now: We have @colours.size colour@if(colours.size > 0){s} the must be a cleaner more reusable way to do this? You can leverage the pimp my lib Scala pattern to implement something equivalent to Play 1.x Java extensions . For example, the pluralize method on collection can be

What is the 'reword' function in Rebol and how do I use it?

梦想的初衷 提交于 2019-12-03 12:22:49
I saw someone mention the reword function today, but documentation for it is very brief. It looks like shell script environment variable substitution, or maybe regex substitution, but different. How do I use this function and what kind of gotchas am I going to run into? Here there be dragons! The reword function is a bit of an experiment to add shell-style string interpolation to Rebol in a way that works with the way we do things. Unlike a lot of Rebol's series functions, it really is optimized for working on just string types, and the design reflects that. The current version is a design

How to customize Upload/Download Template of Blueimp jQuery File Upload

点点圈 提交于 2019-12-03 12:03:07
问题 I'm trying to use the jQuery File Upload Demo. I've searched through wiki & template engine wiki but couldn't find an answer how to customize the Upload/Download template without using table row tag. Each time I remove/change table row tag it does not work. Bellow is my customized upload template and it does not work. I don know why, could somebody please help? uploadTemplate: function (o) { var rows = $(); $.each(o.files, function (index, file) { var row = $('<li class="span3"><div class=