Hello,
I'm assuming that patch like this one might be generally useful.
Kind regards,
Maurice
diff --git a/src/Wt/WTemplate b/src/Wt/WTemplate
index 5adb207..9b9d5dc 100644
--- a/src/Wt/WTemplate
+++ b/src/Wt/WTemplate
@@ -113,7 +113,7 @@ public:
* bound using bindString(). If so, that string is returned. If
* not, it will attempt to resolve a widget with that variable name
* using resolveWidget(), and render it as XHTML. If that fails too,
- * "??" + varName + "??" is appended to the result.
+ * handleUnResolvedString is invoked.
*
* You may want to reimplement this method to provide on-demand
* loading of strings for your template.
@@ -130,6 +130,29 @@ public:
const std::vector<WString>& args,
std::ostream& result);
+ /*! \brief Strings not resolved by the resolveString method are handled
by this method.
+ *
+ * This is the main method used to resolve variables in the template
+ * text, during rendering.
+ *
+ * The default implementation implementation writes
+ * "??" + varName + "??" to the result stream.
+ *
+ * You may want to reimplement this method to provide on-demand
+ * loading of strings for your template.
+ *
+ * The result stream expects a UTF-8 encoded string value.
+ *
+ * \warning When specializing this class, you need to make sure that
+ * you append proper XHTML to the \p result, without unsafe active
+ * contents. The format() methods may be used for this purpose.
+ *
+ * \sa resolveString, renderTemplate()
+ */
+ virtual void handleUnResolvedString(const std::string& varName,
+ const std::vector<WString>& args,
+ std::ostream& result);
+
/*! \brief Resolves a widget for a variable name.
*
* The default implementation returns a widget that was bound using
diff --git a/src/Wt/WTemplate.C b/src/Wt/WTemplate.C
index 251d4ff..5425075 100644
--- a/src/Wt/WTemplate.C
+++ b/src/Wt/WTemplate.C
@@ -88,10 +88,17 @@ void WTemplate::resolveString(const std::string&
varName,
if (w)
w->htmlText(result);
else
- result << "??" << varName << "??";
+ handleUnResolvedString(varName, args, result);
}
}
+void WTemplate::handleUnResolvedString(const std::string& varName,
+ const std::vector<WString>& args,
+ std::ostream& result)
+{
+ result << "??" << varName << "??";
+}
+
WWidget *WTemplate::resolveWidget(const std::string& varName)
{
WidgetMap::const_iterator j = widgets_.find(varName);
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest