Comments (13)
这个java的foreach循环是通过一个方法来获取对象的key为一个数组,具体有哪些方法我也不确定,我所知道的是keySet
,entrySet
这个方法我就不知道了,没有文档说明哪些方法是可用的。
我后面会提供一个接口,可以自己配置这样的方法吧,entrySet
或者keySet
。
from velocity.js.
返回的是 Map,可以看下 API 文档
http://docs.oracle.com/javase/6/docs/api/java/util/Map.html
期待
from velocity.js.
http://git.shepherdwind.com/velocity.js/runner/tests.html?grep=Compile%20Loops%20%23foreach%20with%20map%20entrySet 已经增加entrySet
支持,前面链接是测试用例。不过暂时没有提交到npm上,github上已经同步。
from velocity.js.
谢谢
from velocity.js.
还是上面的例子
$item.key = <script charset="utf-8" src="$staticServer.getURI("/$item.value")"></script>
$item.value 未解析
var property = velocity.render(data, {
assetsServer: {
getURI: function(str) {
return 'http://assets.alipay.net' + str;
}
}
});
from velocity.js.
这个确实是我的一个bug,因为getXXX的方法,都会直接去读取XXX属性。
from velocity.js.
我已经更新了测试用例http://git.shepherdwind.com/velocity.js/runner/tests.html?grep=Compile%20Loops%20%23foreach%20with%20map%20entrySet ,和你的例子一模一样了。你可以再试一下。
另外,给我提bug ,我得感谢你帮我测试才对,呵呵。
from velocity.js.
报告,还是有问题。不支持 ${item.value}
或 $!{item.value}
from velocity.js.
https://github.com/shepherdwind/velocity.js#string 这个问题是已知的。因为vm对字符串的解析,如果是双引号,
类似于php,比较靠谱的方案是重新调用Parser解析字符串,不过,最初考虑到需要在浏览器端跑,所以双引号字符串
使用正则,匹配最简单的变量形式,你提出的这两者不支持。
不过,如果是在node跑的话,性能问题不大,对待浏览器和node还是的分开。
在 2012-12-19,下午6:20,Haoliang Gao [email protected] 写道:
报告,还是有问题。不支持
${item.value} 或 $ !{item.value}—
Reply to this email directly or view it on GitHub.
from velocity.js.
那我觉得可以分开处理,不过浏览器真正的使用场景应该不多吧。
from velocity.js.
还有一种场景
#set($js_file = {
"js_arale":"build/js/arale.js?t=$!{timestamp}",
"js_ma_template":"build/js/ma/template.js?t=20110608",
"js_pa_pa":"build/js/pa/pa.js?t=20110608",
"js_swiff":"build/js/app/swiff.js?t=20110608",
"js_alieditControl":"build/js/pa/alieditcontrol-update.js?t=20110608"
})
#foreach($item in $js_file.entrySet())
$item.key = <script charset="utf-8" src="$staticServer.getURI("/$item.value")"></script>
#end
在 set 的时候定义 timestamp,如果通过两次 parse 是否也能搞定?
from velocity.js.
这种场景和前面的一样,最终都是对双引号的字符串数值。
在 2012-12-20 上午12:28,"Haoliang Gao" [email protected]写道:
还有一种场景
#set($js_file = {
"js_arale":"build/js/arale.js?t=$!{timestamp}",
"js_ma_template":"build/js/ma/template.js?t=20110608",
"js_pa_pa":"build/js/pa/pa.js?t=20110608",
"js_swiff":"build/js/app/swiff.js?t=20110608",
"js_alieditControl":"build/js/pa/alieditcontrol-update.js?t=20110608"
})#foreach($item in $js_file.entrySet())
$item.key = <script charset="utf-8" src="$staticServer.getURI("/$item.value")"></script>
#end在 set 的时候定义 timestamp,如果通过两次 parse 是否也能搞定?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-11536520.
from velocity.js.
在node环境下,增加 https://github.com/shepherdwind/velocity.js/blob/master/src/velocity.js#L6
Compile.Parser = Parser;
https://github.com/shepherdwind/velocity.js/blob/master/src/compile/literal.js#L108 重复执行Parse。已经发布到github上
from velocity.js.
Related Issues (20)
- Dashes in Identifiers HOT 1
- Support format quiet syntax $!{reference}
- String.replace() is not global HOT 2
- Map.remove() is not implemented HOT 2
- String pipe symbol not implemented HOT 1
- Support the $util.qr directive HOT 1
- IE or older browsers not supported!!! HOT 1
- Bug with #set inside #foreach: setting properties on loop variable from foreach doesn't work HOT 1
- TypeError: Cannot read property 'charCodeAt' of undefined HOT 1
- 如何实现webpack的热更新? HOT 2
- String matches does not work HOT 2
- 变量名称是null时报错 HOT 1
- Bug with rendering #foreach and $util.map.copyAndRemoveAllKeys HOT 13
- How to figure out which references in AST are able to be set in context HOT 2
- Support method with arguments HOT 2
- Parse String to Int HOT 2
- ESM module build? HOT 10
- #set with array fails for unknown reason HOT 1
- 无法解析vue中使用element-ui的$message语法 HOT 1
- Date functions not working HOT 2
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.
from velocity.js.