jaded 0.1.0 jaded: ^0.1.0 copied to clipboard
Port of node.js popular Jade view engine for Dart.
jaded #
Port of the excellent Jade view engine in Dart.
Now feature complete with the original jade view engine, please refer to their great documentation to learn about Jade's features and syntax.
Although the aim was to have a high-fidelity port, the major syntactical difference compared with the original Jade (in JavaScript) is that the compiler only emits and executes Dart code, so any embedded code in views must be valid Dart (i.e. instead of JavaScript).
Public API #
import jaded;
// Compile a function
var renderAsync = compile('string of jade', { //Compiler Defaults:
bool pretty: false,
bool compileDebug: false,
String doctype: null,
String filename: null,
bool autoSemicolons: true
});
renderAsync(locals)
.then((html) => print(html));
Options #
locals
Local variable objectfilename
Used in exceptions, and required when using includesdebug
Outputs tokens and function body generatedcompileDebug
Whenfalse
no debug instrumentation is compiledpretty
Add pretty-indentation whitespace to output (false by default)autoSemicolons
Auto add missing semicolons at the end of new lines (true by default)
Current Status #
All tests in jade.test.dart are now passing.
All integration test cases in /test/cases that doesn't make use of an external DSL library are passing, specifically:
filters.coffeescript.jade
filters.less.jade
filters.markdown.jade
filters.stylus.jade
include-filter-stylus.jade
include-filter.jade //markdown
When they become available support for external Web DSL's can be added to transformers.dart in the same way as done inside Jade's feature-rich transformers.js.
Missing eval #
Jade relies on eval'ing code-gen to work which is a limitation in Dart that lacks eval
.
To get around this, we're currently wrapping the code-gen Dart inside an Isolate and writing it
out to a file then immediately reading it back in with spawnUri and invoking the
new code asynchronously in the
runCompiledDartInIsolate() method.
Although this works, it forces us to have an async API to convert jade to html at runtime. When Dart offers a sync API for evaluating Dart code we'll convert it back to a sync API.
Future #
A pre-processor option to pre-generate all the html views at build time which will lets us provide a synchronous API and preload views in a cache avoiding compilation of jade at runtime.
Integrate jaded into the Express web framework as its primary HTML View Engine.
Contributors #
- mythz (Demis Bellot)