1

Using Node.js and express in a MEAN environment, I am looking for a simple and straightforward template engine, meeting these requirements:

  • does not dictate me to only use its own weird syntax but allows me to keep writing webpages using pure/plain html and js
  • supports conditional includes
  • works with express
  • operates on server-side (Node.js/Express)
  • executes freakin' fast ;)

Basically I just want to slice my webpage into several modules (e. g. header, footer, ...) and include those now and then based on simple conditions. I don't want to entirely (re-)rebuild all webpages using a proprietary template language but rather prepare a few html modules that I concatenate at runtime (comparable to PHP where I just use the include instruction to paste prepared html code). I had a look at http://garann.github.io/template-chooser/ and https://github.com/nodejs/node-v0.x-archive/wiki/modules#templating but the sites seem outdated and according to them, there ain't no template engine available fully meeting my requirements!? Suggestions anyone?

5
  • Jade can be an option. jade-lang.com Commented Dec 8, 2015 at 21:41
  • You'll probably want to use EJS which stands for Embedded JavaScript. You can use normal HTML syntax in it. Commented Dec 8, 2015 at 21:45
  • Can I use EJS on server side? Commented Dec 8, 2015 at 21:48
  • John, so jade also allows plain HTML/JS? I thought I had to use its weird syntax? Commented Dec 8, 2015 at 21:49
  • you can use js in jade using script tags: jade-lang.com Commented Dec 8, 2015 at 22:02

1 Answer 1

1

I think ejs is more natural for what you are looking for https://scotch.io/tutorials/use-ejs-to-template-your-node-application, but jade can work also. The example in the link uses partials, which you dont need to use if ur just rendering a single page

Sign up to request clarification or add additional context in comments.

1 Comment

looks promising. i'll check it out. thanks for now =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.