Last Updated: January 28, 2019
·
536
· zhuangya

for a better _.template()

the default underscore template tag is <% %>, it's kind of hard to type for me.

so i change this into ``</code>

_ = require 'underscore'

_.templateSettings = 
  interpolate: /``(.+?)``/g

template = _.template 'Hello ``name``!'

prod = template
  name: 'Mustache'

console.log prod

i think this is way much better ;)

2 Responses
Add your response

Why not {{varName}} for instance? Is it just a matter of your personal prefence or have you some other reasons to do so? I'm just curious.

over 1 year ago ·

@paprikkastudio

you have to type shift + [ / shift + ] for { or } ..

that's tired.

(i'm extremely laze, i know :P)

over 1 year ago ·