void ATemplateNodeHandler_MODEL::Node::process(ATemplateContext& context, AOutputBuffer& output) { AAutoPtr<AEventVisitor::ScopedEvent> scoped; if (context.useEventVisitor().isLogging(AEventVisitor::EL_DEBUG)) { scoped.reset(new AEventVisitor::ScopedEvent(context.useEventVisitor(), ASW("ATemplateNodeHandler_MODEL",26), m_BlockData, AEventVisitor::EL_DEBUG)); } if (m_BlockData.isEmpty()) return; AXmlElement *pElement = context.useModel().useRoot().findElement(m_BlockData); if (pElement) { //a_Found object pElement->emitContent(output); } else { ARope rope("<!--Unable to find element for '",32); rope.append(m_BlockData); rope.append("'-->",4); output.append(rope); } }
/*! Gets text value for a given path thisfunction("element path") lua param: Element path lua return: Text content for a given element or nil if it doesn't exist */ static int alibrary_Objects_Model_getText(lua_State *L) { ATemplateContext *pLuaContext = static_cast<ATemplateContext *>(L->acontext); AASSERT(NULL, pLuaContext); size_t len = AConstant::npos; const char *s = luaL_checklstring(L, 1, &len); const AString& xmlpath = AString::wrap(s, len); AXmlElement *pElement = pLuaContext->useModel().useRoot().findElement(xmlpath); if (!pElement) { return 0; } else { AString str; pElement->emitContent(str); lua_pushlstring(L, str.c_str(), str.getSize()); return 1; } }