root/tlate/std_value.cc

Revision 28939ac15506b95f59142a06b7d6794a801f8198, 1.3 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/*  This file is part of Alue, the multiprotocol Internet discussion daemon
2
3    Copyright © 2010 Antti-Juhani Kaijanaho
4
5    Alue is free software: you can redistribute it and/or modify it
6    under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    Alue is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with Alue.  If not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20#include "std_value.hh"
21#include "string_value.hh"
22
23namespace tlate
24{
25        const std_value::const_ptr std_value::singleton(new std_value);
26
27        value::const_ptr std_value::get(std::string key) const
28        {
29                value::const_ptr rv;
30                /**/ if (key == "hash")   rv.reset(new string_value("#"));
31                else if (key == "dollar") rv.reset(new string_value("$"));
32                else if (key == "obrace") rv.reset(new string_value("{"));
33                else if (key == "cbrace") rv.reset(new string_value("}"));
34                return rv;
35        }
36}
Note: See TracBrowser for help on using the browser.