Created
November 26, 2014 23:48
-
-
Save hail2u/743c518d4b98a29ce812 to your computer and use it in GitHub Desktop.
Handlebars.js のインデント継承により、パーシャル内のpre要素のインデントが増加する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre>This is pre-formatted text, | |
loaded from partial. | |
These lines should not inherit indentation level. | |
</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>pre and Indent Inheritance</title> | |
</head> | |
<body> | |
<h1>pre and Indent Inheritance</h1> | |
<pre>This is pre-formatted text, | |
loaded from partial. | |
These lines should not inherit indentation level. | |
</pre> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strcit'; | |
var fs = require('fs'); | |
var handlebars = require('handlebars'); | |
var render = handlebars.compile(fs.readFileSync('./test.mustache', 'utf8')); | |
var rendered = render({}, { | |
partials: { | |
pre: fs.readFileSync('./pre.mustache', 'utf8') | |
} | |
}); | |
fs.writeFileSync('test.html', rendered); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>pre and Indent Inheritance</title> | |
</head> | |
<body> | |
<h1>pre and Indent Inheritance</h1> | |
{{> pre}} | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment