jadeとnodeを使用し始めました。ノードからヒスイテンプレート(parent.jade
)にオブジェクトを渡していて、同じヒスイファイル(parent.jade
)を別のファイル(child.jade
)に含めています。1つのjadeファイルから別のjadeファイルにサーバーオブジェクトを渡すことはできません
ノードの一部:parent.jade
で次に
res.render('parent.jade', {data: mydata});
は私が正しくデータを受信しています:それは次のように描かれているchild.pug
で
doctype html
html
head
title parent
script(type="text/javascript" src="/resources/file_javascript.js").
var data_from_node = !{JSON.stringify(data)}; //getting the data in javascript file
body(data-title="parent")
div#header(class="wrap")
include header.pug
ul#list(class="nav nav-tabs")
footer(id="footer" class="footer")
include footer.pug
私は親ファイルを含めていますがしかし得ることができませんでしたデータオブジェクト。私は何もなく、すべてのものを試してみましたここで働く私は、次の方法でそれを含めていますされています
doctype html
html
head
title child.pug
body(data-title="child")
div(class="wrap")
include parent.pug //here I am including parent.pug getting the content right
div#mydiv(class="tab-content")
include table.pug
footer(id="footer" class="footer")
include footer.pug
script(type='text/javascript').
var data = !{JSON.stringify(data)}; //getting null here
script(type = "text/javascript", src = "/resources/file_javascript.js")
私はchild.pug
にnullを取得していますのでparent.pug
からchild.pug
の「データオブジェクト」を取得する方法はありますか?