How to render colored text to the console produced by a templating engine which supports looping and variable substitution.
I've done some tests with swig, but it simply escapes the \u001b[32m
stuff.
Is there something in between sprintf
and a real HTML templating engine?
Update:
I've tried swig
for a while now and just using console.log
would've actually been more maintainable/readable :)
Am I the only one that would find something for outputting text to the console based on a model useful? Or am I approaching this from the wrong angle?
Although this doesn't solve the problem of a templating system, it might help you towards what it is you are trying to achieve. There are two different modules that I would suggest you have a look at:
There is a node module called chalk that allows you to define colors/styles though a very simple api.
It is compatible with sprintf
substitution and can be combined with console.log
to log pretty colored formatted output.
If however you are wanting to use it for logs, I'd suggest having a look at bunyan. It allows you to basically send anything to your logs formatted as JSON. It adds extra data like timestamps and error levels, so you don't have to. The output is just JSON, so it can easily be consumed programatically.
By piping the std.out
into bunyan
, it will colorise and format the output, making it easier to inspect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With