Comparing version 0.9.2 to 0.9.3
{ | ||
"name": "razorleaf", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"main": "razorleaf.js", | ||
@@ -5,0 +5,0 @@ "files": ["razorleaf.js"], |
@@ -569,7 +569,11 @@ "use strict"; | ||
function compile(template) { | ||
function compile(template, options) { | ||
if(typeof template !== "string") { | ||
throw new TypeError("Template should be a string."); | ||
} | ||
var tree = parse(template); | ||
var compiled = templateUtilities + "var __top = {attributes: null, content: '', next: null};\n"; | ||
compiled += compileChildren(tree).code; | ||
compiled += compileChildren(tree, options).code; | ||
compiled += "\n\nreturn __top.content;"; | ||
@@ -576,0 +580,0 @@ |
@@ -46,3 +46,3 @@ Razor Leaf is a template engine for HTML. It is indentation-based and vaguely | ||
### `razorleaf.compile(template)` | ||
### `razorleaf.compile(template, [options])` | ||
@@ -53,2 +53,7 @@ Compiles a template and returns a function that renders the template | ||
**`options`** is an object containing options for compilation: | ||
- `loader`: A function that will be called to load parent and included | ||
templates. It is required if either feature is used. | ||
## Syntax | ||
@@ -88,3 +93,3 @@ | ||
JavaScript and include the block if the result is truthy (by the same rules | ||
as JavaScript’s `if`). | ||
as JavaScript’s `if`). It may be followed by an `else` block. | ||
@@ -91,0 +96,0 @@ - `doctype` will insert the string `<!DOCTYPE html>`. |
15536
448
100