From 5e0afb2c9239fd8695ff338f92fe113d593b2bf0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 5 Dec 2011 15:46:44 +0100 Subject: Prepare for template scripts. --- server/src/templateparser.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'server/src/templateparser.cc') diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index b9c65f5..704b215 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -81,6 +81,10 @@ TemplateParser::~TemplateParser() void TemplateParser::characterData(std::string &data) { + if(state == SCRIPT) { + assert(current_script); // No script present! + current_script->code.append(data); + } } void TemplateParser::startTag(std::string name, attributes_t &attr) @@ -127,6 +131,39 @@ void TemplateParser::startTag(std::string name, attributes_t &attr) return; } + // Enable script parsing + if(name == "scripts") { + if(state != MACRO) error("scripts found outside macro."); + state = SCRIPTS; + + assert(t); // No template is currently available, cannot create maps! + + return; + } + + // Create script + if(name == "script") { + + assert(t); // No template is currently available, cannot create script! + + switch(state) { + case SCRIPTS: + { + state = SCRIPT; + + Script s; + s.attributes = attr; + t->scripts.push_back(s); + current_script = &(t->scripts.back()); + } + break; + default: + error("