[Cppcms-users] Template rendering. Access the actual class, rather then members?
Brought to you by:
artyom-beilis
|
From: Abhishek K. <abh...@gm...> - 2014-07-14 16:17:13
|
Greetings,
I have been following the CPPCMS tutorials regarding view rendering.
What I see mostly is that when you render your data (let's use the example
of content::message)
so we have:
content::message c;
c.text=">>>Hello<<<";
render("message",c);
and then in the templates, we use this data as:
<% view message uses content::message %>
<% template render() %>
<html>
<body>
<h1><%= text %> World!</h1> <-- this is a part of message.
</body>
</html>
<% end template %>
<% end view %>
==========================
What I wanted to know, is there a way to access "message" object in the
template, directly? Like instead of doing:
<%= text %>, is there any way where I can refer the actual parent object:
like <%= message.text %> ?
The advantage I will have is, that while calling the render method (as in
render("message",c);), I would be able to pass my data directly.
Let's say in the Message Board's Example. If you see the passing of
data::forum to templates, you were required to construct a parent kind of
object, which would contained vectors to topics, etc. But if you see from
the usage or design point of view, it would be great if I were able to pass
the topics directly, without making it require a parent kind of wrapper.
Let me know, if there exists any way to achieve it.
Regards,
Abhishek
|