mywork's People
mywork's Issues
若不实现 {{{ 的注意事项
如果模板中不实现 {{{html}}}
,就需要在 controller 层处理好内容的HTML转义和安全字符输出
不需要 {{v+1}} 这种语法
不需要
{{v+1}}
这种语法
模板保存简单
如果要做加运算可通过 helper 实现
{{add v 1}}
{
"v":1
}
输出结果
2
需要一个模拟 AJAX 的测试函数
通过字符串定义 ajax 的两种返回值:
$_G['mockajax'](
'/ajax/url/',
'{"status":"success"}',
'{"status":"error","msg":"详细错误消息"}'
)
通过路径读取 json 文件,返回数据
$_G['mockajax'](
'/ajax/login/',
'/mock/login_success.json',
'/mock/login_error.json'
)
/mock/login_success.json
文件内容
{
"status": "success"
}
访问页面 /ajax/url/
时会返回 {"status":"success"}
获取 cookie 中的 NODEAJAX,它是一个JSON字符串。
解析它会变成
NODEAJAX = {
ajax: {
'/ajax/url/': {
type: "error"
}
}
}
如果当前页(/ajax/url/
)的 type 值是 error
,则返回 {"status":"error","msg":"详细错误消息"}
each 的索引和当前实现是 @index 和 this
模板
{{#each list}}
{{@index}} - {{this}} <br>
{{/each}}
数据
{
"list": [
"a",
"b",
"c"
]
}
结果
0 - a <br>
1 - b <br>
2 - c <br>
通过 @Index 和 this 语法实现,不是
{{#each list value index}}
{{/each}}
关于 {php} echo 'test'; {/php}
{php} echo 'test'; {/php}
此语法不应该用于正式的生产环境,因为目前的主体**是前端书写和管理模板,如果里面掺杂 php代码,会导致前端无法复用模板。
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.