Changeset 28939ac15506b95f59142a06b7d6794a801f8198
- Timestamp:
- 08/27/10 18:32:04 (21 months ago)
- Author:
- Antti-Juhani Kaijanaho <antti-juhani@…>
- Children:
- 92c18c14e163e2ab3200ccad6c6c0e6ee5c3e1a6
- Parents:
- 19a2630635324aeed23f74061133ba433a639cd4
- git-committer:
- Antti-Juhani Kaijanaho <antti-juhani@…> (08/27/10 18:32:04)
- Message:
-
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@…>
- Location:
- tlate
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r868b365
|
r28939ac
|
|
| 1 | 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | 2 | |
| 3 | | Copyright © 2009 Antti-Juhani Kaijanaho |
| | 3 | Copyright © 2009, 2010 Antti-Juhani Kaijanaho |
| 4 | 4 | |
| 5 | 5 | Alue is free software: you can redistribute it and/or modify it |
| … |
… |
|
| 185 | 185 | BOOST_CHECK_EQUAL("\n", tester("\n",am)); |
| 186 | 186 | } |
| | 187 | |
| | 188 | BOOST_AUTO_TEST_CASE(std_hash) |
| | 189 | { |
| | 190 | tlate::data_model::ptr am(new tlate::data_model); |
| | 191 | BOOST_CHECK_EQUAL("#", tester("$_.hash$",am)); |
| | 192 | } |
| | 193 | |
| | 194 | BOOST_AUTO_TEST_CASE(std_dollar) |
| | 195 | { |
| | 196 | tlate::data_model::ptr am(new tlate::data_model); |
| | 197 | BOOST_CHECK_EQUAL("$", tester("$_.dollar$",am)); |
| | 198 | } |
| | 199 | |
| | 200 | BOOST_AUTO_TEST_CASE(std_obrace) |
| | 201 | { |
| | 202 | tlate::data_model::ptr am(new tlate::data_model); |
| | 203 | BOOST_CHECK_EQUAL("{", tester("$_.obrace$",am)); |
| | 204 | } |
| | 205 | BOOST_AUTO_TEST_CASE(std_cbrace) |
| | 206 | { |
| | 207 | tlate::data_model::ptr am(new tlate::data_model); |
| | 208 | BOOST_CHECK_EQUAL("}", tester("$_.cbrace$",am)); |
| | 209 | } |
| 187 | 210 | } |
-
|
r868b365
|
r28939ac
|
|
| 1 | 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | 2 | |
| 3 | | Copyright © 2009 Antti-Juhani Kaijanaho |
| | 3 | Copyright © 2009, 2010 Antti-Juhani Kaijanaho |
| 4 | 4 | |
| 5 | 5 | Alue is free software: you can redistribute it and/or modify it |
| … |
… |
|
| 18 | 18 | */ |
| 19 | 19 | |
| | 20 | #include "std_value.hh" |
| 20 | 21 | #include "var.hh" |
| 21 | 22 | |
| … |
… |
|
| 32 | 33 | if (!rv || rv->is_missing()) |
| 33 | 34 | { |
| 34 | | logger::logline ll; |
| 35 | | ll << pos() |
| 36 | | << ": access of a missing variable '" << name << "'"; |
| | 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 | } |
| 37 | 44 | } |
| 38 | 45 | return rv; |