使用安全html模板在gwt中插入空格

时间:2012-11-08 01:58:31

标签: html gwt

我有以下gwt html模板,以便在我的项目中设置面板的标题。

@Template("<div>{0}<span style=\"font-size: 11px;\">{1}</span></div>")
 SafeHtml method1(String title,String subtitle);

如果title =“Hello”和subtitle =“World”,那么上述格式的输出文本是 - &gt;           的HelloWorld

  

我希望上述格式的输出为“Hello”之间的空格   和“世界” - &gt;             Hello World

     

如何在HTML中使用'&amp; nbsp'来在上面的div之间插入一个空格?

     

由于这是一个动态打印标题的模板,我无法使用css   这个头衔。我尝试使用&amp;,但它不起作用。

2 个答案:

答案 0 :(得分:1)

以下工作不正常吗? (即在{0}之后插入一个空格)

@Template("<div>{0} <span style=\"font-size: 11px;\">{1}</span></div>")
SafeHtml method1(String title,String subtitle);

或者您可以使用&nbsp;

@Template("<div>{0}&nbsp;<span style=\"font-size: 11px;\">{1}</span></div>")
SafeHtml method1(String title,String subtitle);

答案 1 :(得分:0)

如果&nbsp;不起作用,您可以在范围上为您的样式添加padding-left: 5px。当你说你不能用css作为标题时,我不确定你的意思。