Mar*_*ark 6 groovy frontend template-engine extend
Groovy允许在前端页面中使用字符串做一些很好的事情,例如:
${"hello".capitalize()}
如何在String课程中添加新的自定义方法?喜欢:
${"hello".custom()}
使用metaClass
String.metaClass.custom = { //dosomething }
Run Code Online (Sandbox Code Playgroud)
见http://www.groovyexamples.org/2010/07/19/dynamically-add-properties-to-a-class/