Project

General

Profile

WT and html template

Added by Jahn Mueller about 3 years ago

Hello,

I am trying to read a html Text using setTemplateText(). However it seems not to be able to read the whole html template.
I tried with the following code lines:
`
...
htmlText += Wt::WString("");
htmlText += Wt::WString("<!DOCTYPE html>");
htmlText += Wt::WString("");
htmlText += Wt::WString("");
htmlText += Wt::WString("Bootstrap and Wt");
htmlText += Wt::WString("");
htmlText += Wt::WString("");
htmlText += Wt::WString("");
htmlText += Wt::WString("");
htmlText += Wt::WString("");
htmlText += Wt::WString("Please enter your name: ${name-edit}");
htmlText += Wt::WString("${save-button} ${cancel-button}");
htmlText += Wt::WString("");
htmlText += Wt::WString("");
htmlText += Wt::WString("");

setTemplateText(htmlText, Wt::TextFormat::XHTML);
...
`

It only works if I provide the function setTemplateText() a div section from the mentioned html text as follows:
`
...
htmlText += Wt::WString("");
htmlText += Wt::WString("Please enter your name: ${name-edit}");
htmlText += Wt::WString("${save-button} ${cancel-button}");
htmlText += Wt::WString("");

setTemplateText(htmlText, Wt::TextFormat::XHTML);
...
`

can you pls tell me what I am missing here?


Replies (2)

RE: WT and html template - Added by Korneel Dumon about 3 years ago

Hi,

a WTemplate does not represent a full html document. It is just a piece of the application that gets inserted in the widget-tree, eg in the root element of WApplication:

auto t = root()->addNew<WTemplate>();
t->setTemplateText(...);

What's the reason you try to put the full document?

RE: WT and html template - Added by Jahn Mueller about 3 years ago

Thank you.

I am trying to store the GUI information in a html file so that it easier to modify later on :).

    (1-2/2)