1.0.4 • Published 8 years ago
pug-templates v1.0.4
Pug-Templates
This is a command-line tool to generate a single JavaScript file from Pug templates to use in browsers.
Installation
npm install -g pug-templatesUsage Examples
$ pug-templates [files...] [options]Options:
-V, --version          output the version number
-d, --dir <directory>  Directory that holds the Pug files
-o, --out <output>     The output file path
-h, --help             output usage informationExamples:
  # complie given Pug files and output templates to destination file:
  $ pug-templates file1.pug file2.pug --out ./outputs/templates.js
  # compile the content of the directory and output templates to destination file:
  $ pug-templates --dir ./examples/ --out ./outputs/templates.jsAfter generating the templates.js you are ready to use it in your HTML files as:
<!DOCTYPE html>
<html>
<head>
  <title>Example</title>
  ...
</head>
<body>
  <div></div>
  <script type="text/javascript" src="/path/to/your/templates.js"></script>
  <script type="text/javascript">
    ...
    var templateHtml = PUG_TEMPLATES["{template file name}"]( yourDataObject );
    ...
  </script>
</body>
</html>Thats it :)