Comments (9)
我这个维护是维护的,不过不想再添加新特性了。
沉鱼那个更新一些,而且错误提示更友好。支付宝内部还有工具在用,推荐你用沉鱼的吧。
很多人问我们两个版本的区别,我这里说下异同吧:
首先这两个库都是基于jison实现的,因为我的早一年时间,沉鱼写的时候,和我探讨过如何实现的细节。
她后来的版本优化了很多我以前写的不好的地方。
另外,实现过程不一样,沉鱼写的时候,应该是首先研究了编译原理那本书的,我则相反,写完velocityjs,然后才发现用的原来是编译原理相关的技术。
其他区别,最大的地方是,我写的没有依赖任何库,所以在浏览器也能跑,但同时,我没有考虑node相关的优化,比如#parse
这种需要开发者自己实现。
最共还有一个共同点,我们都认为velocity模板是很挫的东西,非常不适合node用,语法完全是基于java考虑的,能不用就不用吧。基本没有什么可以优化的空间。
from velocity.js.
最近做的工具需要选一个java和node都支持的模板,可选的余地并不大,所谓模板如果只是语法上的差异其实都是可以接受的。
你能推荐一个其它的模板吗?java和node都支持的模板的。
from velocity.js.
通用模板用velocity肯定是大坑了,我以前用过。比如一个简单地语法:
#if($a) hello #end
这个如果用js来解析,那么如果a是一个空字符串,那么可以输出hello。
但是对于java,你得写$a.size() > 0
或者一个util来判断,这样的语言层面的区别很难抹平的。
再在比如each循环,java的写法和js就完全不一样。
java和node同时支持,这种场景应该不多吧,在支付宝只遇到过一种比较简单的情况,现在的做饭是把velocity模板转换为nunjucks模板,不过这里velocity必须是很简单的语法才行。
from velocity.js.
我现在要做的是,要本地模拟开发环境。 代理mock等都没有问题, 就是模板渲染这块了, 目前公司大部分产品还是用java做的服务器。
主要是js版本支持复杂写法吗? 比如$a.size() > 0
from velocity.js.
就是mock的话,是没有问题的,velocity的js引擎就是为了实现本地mock而实现的。我还以为你是要同时在node和java的线上服务器跑velocity,那样就比较麻烦。
from velocity.js.
对,就是一套模板,本地node环境和服务端java环境 对应一套数据,得到的结果是一致就行。 语法上,我们可以做约定,就是用原始vm的语法。关键是这种语法,是不是js版也支持
from velocity.js.
本地mock是完全可以的。
from velocity.js.
最近也碰到同样的问题,蛋疼的要命
from velocity.js.
建议你的命令改改,这样别人可以共存研究下
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.