richardchen85 / fis-parser-velocity Goto Github PK
View Code? Open in Web Editor NEWA parser for fis to compile velocity template(基于fis的velocity模板解释器)
A parser for fis to compile velocity template(基于fis的velocity模板解释器)
如果将loader设置为"require",页面加载js部分的代码为
require(["/widget/header/header.js", "widget/footer/footer.js"]);
在源码中,可以修改成如下
if(loader) {
arrJs.push(jsFile.substring(1, jsFile.lastIndexOf('.')));
} else {
arrJs.push('<script src="' + jsFile + '"></script>\n');
}
最后页面加载js部分的代码为
require(["widget/header/header", "widget/footer/footer"]);
另外如果采用前端打包方式,即fis3-postpackager-loader,即使将插件的allInOne属性设置为true,依然无法将组件的js打包成一个文件,还需要在page下的html文件中声明依赖:
<!--
@require widget/header/header.js
@require widget/footer/footer.js
-->
所以建议在添加require([])代码时,添加fis的依赖语法,以方便打包。
最后还有一个建议,模版的context或者称之为mock数据,可以使用js文件代替json,好处是可以模拟velocity tool中的一些方法,如$math.floor(),使之更加灵活。
js文件:
module.exports = {}
加载mock数据
require(mockPath);
delete require.cache[mockPath];
最近我也在写一个fis的解析Velocity模版的插件,看了您的代码,收获很多,非常感谢。
1、可以支持下extends与block的语法吗?
我们团队最近想用FIS3来构建前端的项目,恰好我们的后端也是在用Velocity。
现在用您的demo,做如下操作:
cd example\pure
fis3 release -d ../output
提示:[ERROR] parser.0: Cannot find module 'velocity' [E:/Software/nginx/html/FIS/fis-parser-velocity/example/pure/page/index.vm]
不知道是什么原因呢?
https://github.com/fex-team/fis3-jello
如果能跟这个结合就好了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.