Exemplo n.º 1
0
void tag_execute::execute(context &ctx, std::ostream &out, const tag *caller) const {
	const tag *c = ctx.pop();
	if (c) {
		const string &name = get_parameter(ctx, "name");
		if (!name.empty()) {
			tag_tag *t = static_cast<tag_tag*>(c->get_child(string("@") + name));
			if (!t)
				throw tag_exception(
				  (format(_("custom tag '{0}' is not defined at this scope")) % name).str());

			t->execute(ctx, out, c);
			ctx.push(c);

		} else {
			static_cast<const tag_usr*>(c)->execute_direct(ctx, out, this);
		}
	}
}
Exemplo n.º 2
0
void tag_usr::execute(context &ctx, std::ostream &out, const tag *caller) const {
	// create new context layer
	ctx.enter();
	try {
		for (parameters::const_iterator i = params.begin();
		  i != params.end(); ++i) {
			// create and initialize the variable from parameter
			ostringstream s;
			(i->second)->execute(ctx, s, this);
			ctx.add_value(i->first, s.str());
		}

		tag* t = user_tag;
		if (!t) {
			tag *p = parent;
			while (p && !(t = p->get_child("@" + name))) {
				p = p->get_parent();
			}
			if (!t)
				throw tag_exception(
				  (format(_("custom tag '{0}' is not defined at this scope")) % name).str());
		}

		// execute custom tag
		ctx.push(this);
		try {
			static_cast<tag_tag*>(t)->execute(ctx, out, this);
		} catch (...) {
			ctx.pop();
			throw;
		}
		ctx.pop();
	}
	catch (...) {
		// free context layer created
		ctx.leave();
		throw;
	}
	// free context layer created
	ctx.leave();
}
Exemplo n.º 3
0
void tag_usr::execute_direct(context &ctx, std::ostream &out,
  const tag *caller) const {
	tag_impl::execute(ctx, out, caller);
	ctx.push(this);
}