Skip to content

Instantly share code, notes, and snippets.

@hail2u
Created November 26, 2014 23:48
Show Gist options
  • Save hail2u/743c518d4b98a29ce812 to your computer and use it in GitHub Desktop.
Save hail2u/743c518d4b98a29ce812 to your computer and use it in GitHub Desktop.
Handlebars.js のインデント継承により、パーシャル内のpre要素のインデントが増加する
<pre>This is pre-formatted text,
loaded from partial.
These lines should not inherit indentation level.
</pre>
<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>
'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);
<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