【问题标题】:Can I add a meta tag to a particular page that is using templates我可以将元标记添加到使用模板的特定页面吗
【发布时间】:2013-10-18 21:56:42
【问题描述】:

我有一个使用模板的页面

<ui:composition template="/WEB-INF/facelets/templates/clientPage.xhtml">

我希望只使用元标记呈现此特定页面的兼容性视图

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

除非我将它添加到根模板页面,否则该标签不起作用。有没有办法可以将它添加到使用模板的特定页面。

【问题讨论】:

  • 这个问题不清楚。什么样的模板? PHP、Ruby、Javascript、Smarty、Mustache?什么样的相容观,相容于什么?什么元标记?
  • 它是一个 html 模板。我正在使用 JSF。我在stackoverflow.com/questions/11545210/… 中看到了类似问题的答案但是有没有办法在不更改模板页面的情况下做到这一点?
  • 尝试改进您的问题。比你得到更好的帮助。

标签: jsf tags facelets meta


【解决方案1】:

在所需位置的主模板中声明&lt;ui:insert&gt;

clientPage.xhtml

<!DOCTYPE html>
<html ...>
    ...
    <h:head>
        <ui:insert name="head-meta" />
        ...
    </h:head>
    ...
</html>

用另一个主模板扩展主模板:

i18ClientPage.xhtml

<ui:composition template="/WEB-INF/facelets/templates/ie8ClientPage.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
>
    <ui:define name="head-meta">
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    </ui:define>
</ui:composition>

最后让那些模板客户改用这个主模板。

【讨论】:

  • 优秀的 BalusC!
猜你喜欢
  • 2012-10-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多