-
-
Save tommcfarlin/6603d7103286d63e6f29c09cf7a59d8b to your computer and use it in GitHub Desktop.
[JavaScript] The Perfect JavaScript Templating Enging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"tplite": "1.0.3" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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