こんにちは、私はJadeのブロックを使用してnode.jsプロジェクトを拡張しようとしていますが、アイデアは次のようなものです。
layout.jade:
head
script
$(document).ready(function() {
block js_doc_ready
//here goes the doc ready
});
index.jade:
block js_doc_ready
alert('hello!');
alert('one more js line code');
alert('end my js doc ready for this view');
これにより、次のようなindex.htmlが得られます。
...
<head>
<script type="text/javascript">
$(document).ready(function() {
alert('hello!');
alert('one more js line code');
alert('end my js doc ready for this view');
});
</script>
</head>
...
しかし、結果を見ると、「ブロックjs_doc_ready」はJadeブロックとは見なされません。また、ブロックと見なされた場合でも、「alert('hello!);」とは見なされませんが、翡翠のタグと見なされます。
これは私がdjangoテンプレートで行っていたものですが、このすべてのタグが付いた翡翠では、純粋なhtmlを実行する自由がないので、これを作成するには少し奇妙すぎると思います。