nvelocity

NVelocity 操作类VelocityHelper

一个人想着一个人 提交于 2021-02-08 14:51:30
using System; using System.Web; using System.IO; using NVelocity; using NVelocity.App; using NVelocity.Context; using NVelocity.Runtime; using Commons.Collections; using System.Text; namespace FoodunTemplateAction { /// <summary> /// NVelocity模板工具类 VelocityHelper /// </summary> public class VelocityHelper { private VelocityEngine velocity = null; private IContext context = null; /// <summary> /// 构造函数 /// </summary> /// <param name="templatDir">模板文件夹路径</param> public VelocityHelper(string templatDir) { Init(templatDir); } /// <summary> /// 无参数构造函数 /// </summary> public VelocityHelper() { } ///

C#模板引擎NVelocity实战项目演练

被刻印的时光 ゝ 提交于 2021-02-08 14:35:30
一、背景需求 很多人在做邮件模板、短信模板的时候,都是使用特殊标识的字符串进行占位,然后在后台代码中进行Replace字符串,如果遇到表格形式的内容,则需要在后台进行遍历数据集合,进行字符串的拼接,继而Replace模板中的占位符 !今天给大家分享一个WinForm方面的模板引擎的小技巧和小技能吧,本次课程阿笨给大家分享关于WinForm开发中如何通过模板引擎NVelocity根据动态数据生成漂亮的订单详细查看页面? 1.1、本次分享课程包含知识点如下: 1)、WinForm中WebBrowse控件在实际项目中运用。 2)、NVelocity模板引擎在实际项目中运用。 3)、如何优雅的封装NVelocityHelper通过一行代码来初始化模板引擎NVelocity,达到开箱即用! 1.2、一句话总结今天我们要解决的问题? C#如何通过NVelocity模板引擎动态的生成静态的HTML页面。 如果您同样对本次分享《C#模板引擎NVelocity实战项目演练》课程感兴趣的话,那么请跟着阿笨一起学习吧。 废话不多说,直接上干货,我们不生产干货,我们只是干货的搬运工。 二、在线实例演示 NVelocity实例演示 三、NVelocity应用场景和特点介绍 四、实例源码在线解读 来源: oschina 链接: https://my.oschina.net/u/4411942/blog

macros not rendering in NVelocity

青春壹個敷衍的年華 提交于 2020-01-06 05:01:09
问题 I have simple set of velocity templates. When I am trying to merge using NVelocity, the macros from other templates are not executing. The template contents are as follows: V1.vm #parse("V2.vm") #foreach( $customer in $customers) Hello $customer.Name! #set($a =$customer.getage()) #age($a) #end V2.vm #macro ( age $a ) #if($a<18) Minor #else Major #end #end On merge, the output is: Hello User1! #age(33) Hello User2! #age(13) 回答1: The macro doesn't work because NVelocity (and its ancestor

NVelocity ASP.NET Examples

丶灬走出姿态 提交于 2020-01-01 14:40:11
问题 I'm looking to use NVelocity in my ASP.NET MVC application, not as a view engine, just for rendering some email templates. However, I cannot for the life of me get it to work. I have downloaded it from the castle project and followed the example at http://www.castleproject.org/others/nvelocity/usingit.html#step1 No matter what I try I don't seem to be able to load a template located in my site. The example suggests using the absolute path, which I have tried to no avail: Template t = engine

NVelocity ASP.NET Examples

假如想象 提交于 2020-01-01 14:39:49
问题 I'm looking to use NVelocity in my ASP.NET MVC application, not as a view engine, just for rendering some email templates. However, I cannot for the life of me get it to work. I have downloaded it from the castle project and followed the example at http://www.castleproject.org/others/nvelocity/usingit.html#step1 No matter what I try I don't seem to be able to load a template located in my site. The example suggests using the absolute path, which I have tried to no avail: Template t = engine

NVelocity not finding the template

∥☆過路亽.° 提交于 2019-12-21 18:37:32
问题 I'm having some difficulty with using NVelocity in an ASP.NET MVC application. I'm using it as a way of generating emails. As far as I can make out the details I'm passing are all correct, but it fails to load the template. Here is the code: private const string defaultTemplatePath = "Views\\EmailTemplates\\"; ... velocityEngine = new VelocityEngine(); basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, defaultTemplatePath); ExtendedProperties properties = new ExtendedProperties();

NVelocity not finding the template

蹲街弑〆低调 提交于 2019-12-21 18:36:01
问题 I'm having some difficulty with using NVelocity in an ASP.NET MVC application. I'm using it as a way of generating emails. As far as I can make out the details I'm passing are all correct, but it fails to load the template. Here is the code: private const string defaultTemplatePath = "Views\\EmailTemplates\\"; ... velocityEngine = new VelocityEngine(); basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, defaultTemplatePath); ExtendedProperties properties = new ExtendedProperties();

Template in monorail ViewComponent

假装没事ソ 提交于 2019-12-11 07:23:58
问题 Is it possible to have a template with html content in vm for a block component? I'm doing a lot of stuff in html, and want the html reside in a .vm, not in codebehind. Here is what i've got: public class TwoColumn : ViewComponent { public override void Render() { RenderText(@" <div class='twoColumnLayout'> <div class='columnOne'>"); // Context.RenderBody(); Context.RenderSection("columnOne"); RenderText(@" </div> <div class='columnTwo'>"); Context.RenderSection("columnTwo"); RenderText(@" <

NVelocity advance lopping syntax

拥有回忆 提交于 2019-12-11 03:37:00
问题 Currently I am doing a project which involve Nvelocity template, however, I need use advance foreach, I could find the reference, just I could not figure out how does it works,reference link #foreach($l in $markPoint)hardcodetext($l)#end however, I need add "," between items,hardcode will left one after last item, which I don't want, any helps? 回答1: The NVelocity special foreach looping directives are just nested sections inside the foreach directive, which you define bits of the template.

Automatically HTML Encoding NVelocity Output (EventCartridge & ReferenceInsert)

别来无恙 提交于 2019-12-10 20:07:46
问题 I wanted to try getting NVelocity to automatically HTML encode certain strings in my MonoRail app. I looked through the NVelocity source code and found EventCartridge , which seems to be a class which you can plugin to change various behaviours. In particular this class has a ReferenceInsert method which would seem to do exactly what I want. It basically gets called just before the value of a reference (e.g. $foobar) gets output, and allows you to modify the results. What I can't work out is