2013-10-10 20 views
1

我有一個使用模板我可以將元標記添加到特定頁面,使用模板

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

我希望只渲染使用meta標記

這個特定頁面的兼容性視圖頁面
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> 

標記不起作用,除非我將它添加到根模板頁面。有沒有一種方法可以將它添加到使用該模板的特定頁面。

+0

這個問題還不清楚。什麼樣的模板? Php,Ruby,Javascript,Smarty,小鬍子?什麼樣的可操作性觀點,對什麼有效?什麼meta標籤? – Meier

+0

它是一個html模板。我正在使用JSF。我在http://stackoverflow.com/questions/11545210/how-to-add-meta-tag-in-header-when-using-template看到類似問題的答案但是有沒有辦法做到這一點,沒有任何更改模板頁面? –

+0

試着改善你的問題。比你得到更好的幫助。 – Meier

回答

0

在期望的位置中聲明的主模板的<ui:insert>

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> 

最後讓這些模板客戶端改用這個主模板。

相關問題