1 /** Contains common types and constants.
2 */
3 module diet.defs;
4 
5 import diet.dom;
6 
7 
8 /** The name of the output range variable within a Diet template.
9 
10 	D statements can access the variable with this name to directly write to the
11 	output.
12 */
13 enum dietOutputRangeName = "_diet_output";
14 
15 
16 /// Thrown by the parser for malformed input.
17 alias DietParserException = Exception;
18 
19 
20 /** Throws an exception if the condition evaluates to `false`.
21 
22 	This function will generate a proper error message including file and line
23 	number when called at compile time. An assertion is used in this case
24 	instead of an exception:
25 
26 	Throws:
27 		Throws a `DietParserException` when called with a `false` condition at
28 		run time.
29 */
30 void enforcep(bool cond, lazy string text, in ref Location loc)
31 {
32 	if (__ctfe) {
33 		import std.conv : to;
34 		assert(cond, loc.file~"("~(loc.line+1).to!string~"): "~text);
35 	} else {
36 		if (!cond) throw new DietParserException(text, loc.file, loc.line+1);
37 	}
38 }