tj / consolidate.js

Template engine consolidation library for node.js
3.48k stars 357 forks source link

generic javascript interpolation #316

Closed brewster1134 closed 5 years ago

brewster1134 commented 5 years ago

im not familiar with all the supported engines, but would supporting a generic type that simply interpolates any file using the standard js ${expression} syntax? consolidate.js seems like a good home for a simple solution for template literals. the use case i ran into, was i wanted to be able to process a css file for testing, with some variable values. for example to pass { color: { error: 'red' }} to test.css

body{
  color: ${colors.error}
}
doowb commented 5 years ago

I don't think any of the libraries that consolidate supports right now support that type of syntax (I thought ejs did, but I quickly looked through their docs and don't see reference to it).

If you find one and would like to do a PR to include it in consolidate, I'll review it and merge it in. For your use case, it might be better to use the template engine directly (unless this is part of a larger app that already uses consolidate).

I'm going to close this issue, but feel free to keep the discussion going here.

brewster1134 commented 5 years ago

yeah i was thinking this could be an internal consolidate feature, since it would require the exact API the consolidate provides... a simple logic-less interpolation option.