CppCMS渲染content中内容到页面上
来源:互联网 发布:java程序员做什么 编辑:程序博客网 时间:2024/06/07 05:27
框架见文章Creating a simple web prototype based on CppCMS
我们只需要更改头文件content.h
#ifndef CONTENT_H #define CONTENT_H #include <cppcms/view.h> namespace Content { struct PageContent : public cppcms::base_content { string text ; }; } #endif在struct中添加一个string成员变量text, 然后在Site.cc中给其赋值
#include "controller/site.h" #include <cppcms/url_dispatcher.h> #include "model/content.h" #include <cppcms/http_file.h> using namespace std; Site::Site(cppcms::service &srv):cppcms::application(srv) { dispatcher().assign("/page" , &Site::Page, this);} void Site::Page() { Content::PageContent content; content.text = "hello world"; render("page","page_view", content); }
最后改一下page.tmpl文件
<% c++ #include "model/content.h" %> <% skin page%> <% view page_view uses Content::PageContent %> <% template render() %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> </head> <body> <h1> <%= text %></h1> </body> </html> <% end template %> <% end view %> <% end skin %>
编译运行程序后会在页面显示hello world
0 0
- CppCMS渲染content中内容到页面上
- 加载ajax内容到页面后的样式重新渲染需$().listview('refresh');
- CPPCMS从编译到开始
- CSS3之利用选择器和content属性在页面中插入内容
- CSS3之利用选择器和content属性在页面中插入内容
- PHP配置使PHP在页面中支持<?= $content; ?>输出内容
- 关于mustacheJS模板渲染页面内容
- Web页面上中显示word中的内容
- Web页面上中显示word中的内容
- 将数据库中内容展示在前台页面上
- servlet 中 printWriter打印到页面内容 中文乱码
- servlet 中 printWriter打印到页面内容 中文乱码
- JSP页面 鼠标移动到页面元素上时,显示完整内容
- Ajax获取数据渲染到页面
- 从输入URL到页面渲染完成
- 微信小程序 textarea 复制一大段内容粘贴到内容框,所有文字会往上推,在页面上看不到内容
- iOS中OpenGL是如何将帧缓冲(frameBuffer)渲染到屏幕上的? OpenGL iOS端渲染流程
- web content 嵌入到应用上
- 【畅言】不把C作为第一门语言是个好主意么?-----转自 http://www.csdn.net/article/2014-07-01/2820467
- U872-结算成本处理步骤及索引处理
- 云计算里的安全:警惕云服务被恶意利用
- MongoDB数据库插入、更新和删除操作详解
- 实用简约的JAVA注释标签-高手必备
- CppCMS渲染content中内容到页面上
- 无需App Store,无线发布iOS应用(OTA)
- 内存泄露错误
- Mac 下 Chrome多个Tab之间切换
- 第一篇:知识库,Apache Jena,DL,Description Logic,Ontology。
- 监控 Linux 性能的 18 个命令行工具(转)
- 后缀数组+二分poj3261
- poj 1852 ants(模拟+想象力)
- Android exploit with a Qualcomm processor (CVE-2012-4220)