dag
0.1.2, released 2 months ago by finchdart.com
Transpiles .dag files containing text and embedded Dart code into plain .dart source files.
What it does
Transpiles .dag files—which mix literal output text with embedded Dart code PHP-style—into plain .dart source code. It features whitespace control, parameter definitions, hoisting of imports, and supports compilation via a CLI tool or package:build.
AI-written summary of version 0.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to generate text, HTML, or code using PHP-style template files where the file compiles directly to Dart code.
- You want compile-time transpilation of text-with-code files rather than runtime template interpretation.
Skip it when
- You need a standard runtime template engine.
- Your project cannot use code generation or the provided CLI tools.
Strengths
- Compiles directly to real Dart code with zero runtime interpretation overhead.
- Supports both a CLI tool and a package:build Builder via build_runner.
- Provides helpful DagError traceback reporting exact .dag file line numbers.
Weaknesses
- A literal '?>' inside a tag's Dart code will close the tag early.
- Requires a build pipeline or CLI step during development.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 4
Add the package via pub add dag and either use the CLI tool or integrate with build_runner.
import 'package:dag/dag.dart';
final dartSource = transpile(dagSource);Alternatives
Packages that do the same job and could replace dag.
Works with
Packages commonly used together with dag: ones it builds on, ones built on it, and its own family.
- watcherdag depends on itMonitors file system changes and notifies when files are added, removed, or modified.
- argsdag depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- builddag depends on itPackage for authoring build_runner compatible code generators.
- build_runnerUsed togetherA build system for Dart code generation and modular compilation.
- finchBuilt on dagA lightweight Dart framework for building server‑side web apps, APIs, databases and WebSockets.