Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active September 28, 2017 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/6603d7103286d63e6f29c09cf7a59d8b to your computer and use it in GitHub Desktop.
Save tommcfarlin/6603d7103286d63e6f29c09cf7a59d8b to your computer and use it in GitHub Desktop.
[JavaScript] The Perfect JavaScript Templating Enging
(function($) {
'use strict';
var _getShop = function() {
var shopHtml =
"<h1>" +
"{{title}}" +
"</h1>";
return shopHtml;
}
$(function() {
var template = new tplite.Template();
var buffer = new tplite.StringBuffer();
var compile = template(_getShop());
compile({
title: 'Hello World!'
}, buffer);
});
})(jQuery);
{
"dependencies": {
"tplite": "1.0.3"
}
}
<?php
wp_enqueue_script(
'tplite-js',
$this->pluginUrl . 'node_modules/tplite/dist/tplite-all.min.js'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment