在Freemarker消息中间插入内联样式 [英] Insert inline styles in the middle of a Freemarker message

查看:78
本文介绍了在Freemarker消息中间插入内联样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Freemarker对发送的电子邮件进行模板化,以通知用户新邮件。我想做的是能够显示具有以下格式和重点的消息:

I'm using Freemarker to template emails being sent out to notify users of new messages. What I'd like to do is be able to display a message with this formatting and emphasis:

您好,用户1!您收到了一条新消息来自用户2的邮件标题

"Hello User 1! You've received a new message Message Title from User 2"

为此,我将邮件分成两部分,然后放入邮件标题在中间使用字体样式:斜体,如下所示:

To do this I'm splitting the message up into two bits, then putting the Message Title in a span in the middle with font-style: italic, like so:

${message("MsgNotificationEmail.receivedNewMsg1"), recipientName}
<span style="font-style:italic;">${msgTitle}</span>
${message("MsgNotificationEmail.receivedNewMsg2", senderName)}

是否更整洁在消息中间应用样式而又不需要像这样分解样式的方法?

Is there a neater way to apply styles in the middle of a message without needing to break it up like this?

推荐答案

在FreeMarker的典型应用中看起来像这样:

In a typical application of FreeMarker it would look like this:

Hello ${recipientName}!
You've received a new message <span style="font-style:italic;">${msgTitle}</span>
from ${senderName}

也就是说,您没有 receivedNewMsg1 加上 receivedNewMsg2 加上模板,只是一个模板。

That is, you don't have receivedNewMsg1 plus receivedNewMsg2 plus a template, just a single template.

这篇关于在Freemarker消息中间插入内联样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆