dag 0.1.0
dag: ^0.1.0 copied to clipboard
Transpiles .dag files (plain text with embedded Dart code, PHP-style) into plain .dart source files. Not a template engine: the .dag file IS Dart code, interleaved with literal text, exactly like a .p [...]
0.1.0 #
Initial release.
- Transpile
.dagfiles (literal text with embedded Dart, PHP-style) into plain.dartsource. Not a template engine — a.dagfile compiles to real Dart, evaluated at compile time, not interpreted at runtime. - Tags:
<?dag ... ?>(raw code, inserted verbatim — can open/close a block across multiple tags, e.g.if (x) {...}),<?dag= expr ?>(echo an expression),<?dag:imports ?>(deduped, hoisted to file top),<?dag:params ?>(render function's parameter list),<?dag:name ?>(rename the generated function, defaultrender). - Generated function is always
Future<String> ... async, so any echo or code canawaitaFuture/Future<String>with no extra setup. - Runtime errors are rethrown as
DagError, carrying the original error, its stack trace, and the exact.dagfile + line that caused it — via a singletry/catcharound the whole function body plus a cheap line-tracking variable (no per-statement try/catch overhead). - Whitespace control:
<?dag- ... ?>/<?dag ... -?>/<?dag- ... -?>trim adjacent whitespace independently on each side (Twig-style), with<?-as shorthand for<?dag-. Lets structural tags (for,if,}) sit on their own line without leaking a blank line into the output. dagCLI (dart run dag:dag <file|dir> [--out] [--watch]) for file/directory transpilation with optional watch mode.package:buildBuilder(lib/builder.dart, registered viabuild.yaml) so.dag -> .g.dartcan run throughbuild_runneras part of a normal Dart build pipeline.