kc-tagfun

[js] Replace content within tags with function's output.

Usage no npm install needed!

<script type="module">
  import kcTagfun from 'https://cdn.skypack.dev/kc-tagfun';
</script>

README

TagFun

[js] Replace content within tags with function's output.

Install

npm install kc-tagfun

Use

var tagfun = require('kc-tagfun');
var tg1 = '{{'; // Open tag
var tg2 = '}}'; // Close tag
var tpl = '{{2+2}} is a number'; // Template
var str = tagfun(tpl, tg1, tg2, function(c){
    return eval(c);
}); console.log(str);