UNSOLVED Consolidation of template languages

  • As I'm sure you guys are aware, TJ Holowaychuk made a npm library named consolidate which, how befittingly, consolidates all different template languages on Node.js

    Obviously, since they're both from the same author, consolidate is fully express-compatible middleware which allows a user to easily write templates in their own preferred templating language.

    Now there are a lot of things I like about Nodebb but the <!-- IF somethingFoo --> kind of template conditionals make my eyes want to bleed.

    Is there any attempt, initiative or plans to support more template languages? I assume this is relatively easy to achieve although there may be implementation concerns of which I am unaware, hence the question before I run off to go make something.

  • GNU/Linux

  • GNU/Linux Admin

    Yes, I'd love it if NodeBB could use different template engines based on template suffix.

    However, templates.js is both server and client-side, which not all template engines are...

    Looping in @psychobunny for his thoughts 🙂

  • Admin

    One reason why we rolled our own template engine was so that we could customise and optimise it specifically for NodeBB's needs.

    Additionally, the syntax follows for the most part Smarty-style syntax, which is the main reason why we built our own JS version of Smarty. The syntax is familiar to devs coming from phpBB (such as myself) and vanilla forums, amongst others.

    The original idea was that it'd be easier to convert themes from other forums to ours.

    Anyways, that game plan is up for debate, but I am looking forward to seeing what @bogus can accomplish with his templating abstraction layer 🙂

  • GNU/Linux

    @psychobunny my template abstraction layer looks working for me 🙂
    Unfortunately the project in which I hoped to use NodeBB is wanished.
    But I'm still not lost my interest. PR was fired and waiting for review 🙂

    Maybe I'll make my own theme fully with Jade. Some day... 🙂

    As for supported template engines - there are modules for t.js templates and for Jade. I can add more engines if anyone needed.

    Main unresolved problems are:

    • rendering of template block is supported only with t.js For other engines I only pass special variable that indicates what block is requested so it can be considered on template level
    • calling helpers is quite complicated in t.js so you have to be carefull when using partials with another engine
    • no generic cross-engine imports and partials

    I personaly don't think that these problems overweight benefits granted.

Suggested Topics

| |