admin 管理员组文章数量: 1086019
I need to browse files in a directory using velocity syntax, while working with C#. No solution found yet for C# lang env. All relevant answers are regarding Java that requires to create a specific Java class to do that. A Java class can be used in a template with "$loader".
How can I tailor it according to C#?
.vm
json-from-file.vm - It's using $fn.fileFromBundle("foo.json") but:
Single File: $fn.fileFromBundle("foo.json") works for one file, but I need all JSONs (Product.json, Order.json). No Folder Scan: Telosys Velocity lacks a method to list files in a directory (e.g., no $fn.filesFromBundle()). My Snag: I kept trying to find a native Velocity way to browse TelosysTools\templates\json-to-entity—it doesn’t exist.
In fact, I want to create .entity files from .json files. telosys requires "ne EntityName" to create empty .entity file. One command per entity. I have created a .txt file that will create .entity files using json-to-entity.vm for all the json files placed in adirectory. And then gen * *.
telosys-cmd.txt:
m product-model
b json-to-entity
gen * * -y
b csharp-bundle
gen * * -y
exit
Is there any way to achieve this using json-from-file.vm
I need to browse files in a directory using velocity syntax, while working with C#. No solution found yet for C# lang env. All relevant answers are regarding Java that requires to create a specific Java class to do that. A Java class can be used in a template with "$loader".
How can I tailor it according to C#?
https://github/telosys-templates/text-files-usage/blob/master/json-from-file.vm
json-from-file.vm - It's using $fn.fileFromBundle("foo.json") but:
Single File: $fn.fileFromBundle("foo.json") works for one file, but I need all JSONs (Product.json, Order.json). No Folder Scan: Telosys Velocity lacks a method to list files in a directory (e.g., no $fn.filesFromBundle()). My Snag: I kept trying to find a native Velocity way to browse TelosysTools\templates\json-to-entity—it doesn’t exist.
In fact, I want to create .entity files from .json files. telosys requires "ne EntityName" to create empty .entity file. One command per entity. I have created a .txt file that will create .entity files using json-to-entity.vm for all the json files placed in adirectory. And then gen * *.
telosys-cmd.txt:
m product-model
b json-to-entity
gen * * -y
b csharp-bundle
gen * * -y
exit
Is there any way to achieve this using json-from-file.vm
Share Improve this question edited Mar 27 at 13:05 saibin asked Mar 27 at 12:16 saibinsaibin 254 bronze badges1 Answer
Reset to default 0Telosys is written in Java. Therefore, it only supports extensions written in Java and loaded with $loader in a template file.
So, you'll need to create and compile a small Java8 utility class to retrieve the files located in a given directory. It's quite simple; you'll find many examples online.
本文标签: telosys Browse a directory in Velocity with c envStack Overflow
版权声明:本文标题:telosys Browse a directory in Velocity with c# env - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744090353a2531916.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论