goji
Version:
An HTML templating engine inspired by Thymeleaf
110 lines (85 loc) • 3.03 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: goji.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: goji.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>'use strict';
var Compiler = require('./lib/Compiler');
var compiler;
/**
* Goji is a template engine inspired by
* <a href="http://thymeleaf.org/">Thymeleaf</a>. It uses regular HTML
* as the template "language".
*
* @param {Complier~Options} options Defines the options Goji will use during
* compilation and rendering
* @returns {Goji}
* @constructor
*/
function Goji(options) {
if (! (this instanceof Goji)) {
return new Goji(options);
}
compiler = new Compiler(options);
}
/**
* Takes a string template and parses it for includes.
*
* @param {string} template An HTML document or snippet
* @param {Compiler~Options} options Defines the options Goji will use during
* compilation and rendering. Note: this will overwrite whatever
* options were specified in the initial constructor.
* @returns {Compiler~RenderFunction}
*/
Goji.prototype.compile = function gojiCompile(template, options) {
return compiler.compile(template, options);
};
/**
* Clears Goji's internal cache of templates. Does nothing if you disabled
* caching.
*/
Goji.prototype.emptyCache = function gojiEmptyCache() {
compiler.emptyCache();
};
/**
* Looks for a template with the given name in the templates directory
* (as specified by the {@link Compiler~Options}). Once found, the template
* is read in and returned as a string. This string can then be used
* with the {@link Goji#compile} method.
*
* @param {string} name The name of a template. E.g. if you have a template
* file "foo.html", you would simply provide "foo" as the name
* @returns {string|null} The template as a string or null if the template
* could not be found
*/
Goji.prototype.loadTemplateNamed = function gogiLoadTemplate(name) {
return compiler.loadTemplateNamed(name, false);
};
exports = module.exports = Goji;</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Compiler.html">Compiler</a></li><li><a href="Goji.html">Goji</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.1</a> on Tue Jun 09 2015 14:05:51 GMT-0400 (EDT)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>