Introducing Our New Templating Engine
-
@shard it's in the benchpressjs branch of the nodebb repository at the moment.
-
There are docs up on the Github page detailing syntax and behavior. There is a new alternate syntax available,
{{{ if isTrue }}} is true {{{ end }}}
, and that should make things easier as the behavior of the alternate syntax is more predictable in several usage areas. -
Well, for me NodeBB works great. I run it on a micro instance and resource consumption is very low. There were some minor issues, but overall I'm very happy with it. I just don't use plugins which are unsupported, i think this is a common sense when deploying open source code developed by community. I think it could be useful (and it will help to avoid a lot of confusion) if we put plugins into different categories: stable (always tested with every new release of NodeBB), and unstable (use at your own risk), this model works well for Debian Linux, that has three branches: Stable, Testing and Unstable (sid).
-
-
Why didn't you use Twig.js? Twig.js is the fastest template engine in javascript, and also the most powerful. You can look at the design, every possible optimization is made.
-
@razr-world twig is not compatible with templates.js syntax.
Also, it's tough claiming to be faster than Benchpressjs. I haven't seen any benchmarks comparing the two.
-
@razr-world I don't see anywhere that makes these claims, but they both compile to JS, so the performance should be similar.
I'd like to see actual benchmarks as well.
-
template-benchmark
There you go, published results. It looks like Twig.js is even slower than templates.js was, and much slower than Benchpress. I am a little dubious of those results, though, as I could have easily messed something up in the benchmark.
-
There's one more breaking change that I did not find documented anywhere.
For our theme we had to change:var templates = require('templates.js'); templates.registerHelper('generateCategoryBorder', helpers.generateCategoryBorder);
to
var Benchpress = require('benchpressjs'); Benchpress.registerHelper('generateCategoryBorder', helpers.generateCategoryBorder);
Not a big deal but some folks might struggle to see why their template helpers don't work on server side.
-
-