Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当使用filter并传递参数时输出不合预期 #9

Closed
otakustay opened this issue Dec 22, 2013 · 0 comments
Closed

当使用filter并传递参数时输出不合预期 #9

otakustay opened this issue Dec 22, 2013 · 0 comments
Assignees

Comments

@otakustay
Copy link
Member

var etpl = require('etpl')
etpl.addFilter('trim', function (s, space) { return s.substring(space) })
var render = etpl.compile('${id | trim(${space})}')
var data = { id: 'abc', space: 1 }
render(data)
// -> "${id | trim(1)}"

已经修复了 #8 的错误保证能顺利执行

预期输出应该是abc在截取掉1位(space控制)后的字符串,即"bc",但真实输出是"${id | trim(1)}",逻辑不大能分析出来……似乎trim本身也没有执行

@ghost ghost assigned erik168 Dec 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants