Velocity vs. FreeMarker [closed]

The goals for the projects are different. Velocity’s goal is to keep templates as simple as possible, to help maintain a segregation between logic and presentation, so you don’t slide down the slippery slope of sticking code in templates. Sometimes this is the right thing. Of course, sometimes being able to wire complicated logic directly … Read more

How to create global variables accessible in all views using Express / Node.JS?

After having a chance to study the Express 3 API Reference a bit more I discovered what I was looking for. Specifically the entries for app.locals and then a bit farther down res.locals held the answers I needed. I discovered for myself that the function app.locals takes an object and stores all of its properties … Read more

How do I use Django templates without the rest of Django?

The solution is simple. It’s actually well documented, but not too easy to find. (I had to dig around — it didn’t come up when I tried a few different Google searches.) The following code works: >>> from django.template import Template, Context >>> from django.conf import settings >>> settings.configure() >>> t = Template(‘My name is … Read more

Truncate string in Laravel blade templates

In Laravel 4 & 5 (up to 5.7), you can use str_limit, which limits the number of characters in a string. While in Laravel 5.8 up, you can use the Str::limit helper. //For Laravel 4 to Laravel 5.5 {{ str_limit($string, $limit = 150, $end = ‘…’) }} //For Laravel 5.5 upwards {{ \Illuminate\Support\Str::limit($string, 150, $end=’…’) … Read more

How to use underscore.js as a template engine?

Everything you need to know about underscore template is here. Only 3 things to keep in mind: <% %> – to execute some code <%= %> – to print some value in template <%- %> – to print some values HTML escaped That’s all about it. Simple example: var tpl = _.template(“<h1>Some text: <%= foo … Read more