Natural Templating .html (like Thymeleaf) for Node.js
Asked Answered
B

4

14

Is there Natural Templating for Node.js

Natural Templating (like Thymeleaf template engine) is when template page or it's part can be perfectly displayed by a browser as a prototype, without being executed at all. That is, I have template with .html extension, and I can just open in browser to preview it, and use standard HTML dev tools to edit.

UPDATE: I have added answered, that were added in comments. (Do new StackOverflower users fear to add answers?) Hope to hear from developers, that actually use those things (just add new answer)

Beaujolais answered 27/3, 2013 at 5:43 Comment(6)
like github.com/flatiron/plates?Botheration
I use mustache; works fine enough - mustache.github.comDivergent
@RomanNewaza That's pretty strict. What would you use instead of templates?Propound
I don't think they answered because, technically, plates and mustache are not "natural templating" engines so they aren't the answer.Mopey
I very much like this question. The only Natural Templating alternative I'm seeing is AngularJS. But it doesn't work with NodeJS for server-side rendering as far as I know.Krp
github.com/ultraq/thymeleafjs what about this?Leveille
B
5

github.com/flatiron/plates (answered by generalhenry)

Plates (short for templates) binds data to markup. Plates has NO special syntax. It works in the browser and in Node.js.

Active

Beaujolais answered 28/3, 2013 at 5:32 Comment(2)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.Washin
Can you link to examples that show how Plates is used with large amounts of HTML (not ust simple one-liners)? For example, I want to see how Plates is used with an entire and complete HTML layout. The examples on the github page show only one line use cases.Mopey
S
0

I have a jinja like template engine in the backend.

My frontend sometimes needs to retrieve data from the server and interpolate with the content of a HTML5 template tag.

I could do that with query selectors. But I want something more closer to thymeleaf or mustache without special syntax (especially not to conflict with my backend template engine and not have any issues when presented in the HTML5 template tag).

So I created this:

https://github.com/marcodpt/tint

While this works in the browser (and that's fine for my personal use), it's not difficult to use a DOM API to port it to node or deno.

<html>
  <head>
    <script type="module">
      import compile from "https://cdn.jsdelivr.net/gh/marcodpt/[email protected]/template.js"
      const render = compile(document.getElementById("app"))
      render({
        message: "Hello World!"
      })
    </script>
  </head>
  <body>
    <div id="app">
      <h1 :text="message">Loading...</h1>
    </div>
  </body>
</html>    
Seismology answered 9/9, 2022 at 21:1 Comment(0)
B
-2

{{ mustache }} (answered by etienne)

Logic-less templates.

Available in Ruby, JavaScript, Python, Erlang, PHP, Perl, Objective-C, Java, .NET, Android, C++, Go, Lua, ooc, ActionScript, ColdFusion, Scala, Clojure, Fantom, CoffeeScript, D, and for node.js.

Works great with TextMate, Vim, Emacs, and Coda.

Beaujolais answered 28/3, 2013 at 5:33 Comment(2)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.Washin
this is exactly what OP does not want, this is not a natural templatingPenelope
S
-2

I was using Handlebars.

There are actually quite a few template engines in JavaScript and here you can decide what you need.

Steamy answered 9/4, 2015 at 13:48 Comment(1)
this is exactly what OP does not want, this is not a natural templatingPenelope

© 2022 - 2024 — McMap. All rights reserved.