|
Revision 28939ac15506b95f59142a06b7d6794a801f8198, 1.7 KB
(checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 21 months ago)
|
|
Allow templates access to literal special characters
The variable "_" refers by default now to a structured value having
the following members:
- hash containing "#"
- dollar containing "$"
- obrace containing "{"
- cbrace containing "}"
So, for example, $_.dollar$ in a template will, in general, expand to
the dollar sign.
Closes #75.
Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>
|
-
Property mode set to
100644
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #include "std_value.hh" |
|---|
| 21 | #include "var.hh" |
|---|
| 22 | |
|---|
| 23 | #include "../logger/logline.hh" |
|---|
| 24 | |
|---|
| 25 | namespace tlate |
|---|
| 26 | { |
|---|
| 27 | bool var::is_value_missing(overriding_structured_value::ptr env) { |
|---|
| 28 | value::const_ptr rv = env->get(name); |
|---|
| 29 | return !rv || rv->is_missing(); |
|---|
| 30 | } |
|---|
| 31 | value::const_ptr var::eval_(overriding_structured_value::ptr env) { |
|---|
| 32 | value::const_ptr rv = env->get(name); |
|---|
| 33 | if (!rv || rv->is_missing()) |
|---|
| 34 | { |
|---|
| 35 | if (name == "_") |
|---|
| 36 | rv = std_value::singleton; |
|---|
| 37 | else |
|---|
| 38 | { |
|---|
| 39 | logger::logline ll; |
|---|
| 40 | ll << pos() |
|---|
| 41 | << ": access of a missing variable '" |
|---|
| 42 | << name << "'"; |
|---|
| 43 | } |
|---|
| 44 | } |
|---|
| 45 | return rv; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | } |
|---|