pug-templates

Command-line tool to generate templates from Pug files into a single JavaScript file for use in browsers

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-templates

Usage 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 information

Examples:

# 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.js

After generating the templates.jsyou 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 :)

HomePage

https://github.com/alekperos/pug-templates#readme

Repository

https+https://github.com/alekperos/pug-templates


上一篇:fusox
下一篇:apysignature

相关推荐

  • 关于pug的笔记

    一、简介 Pug 是一款健壮、灵活、功能丰富的模板引擎,专门为 Node.js 平台开发。Pug 是由 Jade 改名而来,他可以帮助我们写html的时候更加的简单明了。

    2 年前
  • x-templates

    simple dom based templating of JSON and DOM trees using css selectors Build Status(https://travisci...

    4 个月前
  • uri-templates

    URI Templates (RFC6570) including desubstitution uritemplates URI Templates (RFC6570(http://tools...

    1 年前
  • the-templates

    Templates for theprojects thetemplates ========== Build Statusbdtravisshieldurlbdtravisurl np...

    20 天前
  • templates.js

    An ultralight and super fast templating framework Build Status(https://travisci.org/psychobunny/...

    9 个月前
  • templates

    System for creating and managing template collections, and rendering templates with any node.js temp...

    2 年前
  • swig-templates

    A simple, powerful, and extendable templating engine for node.js and browsers, similar to Django, Ji...

    2 年前
  • swig-email-templates

    Node.js module for rendering emails with swig templates and emailfriendly inline CSS swigemailtemp...

    9 个月前
  • spritesheet-templates

    Convert spritesheet data into CSS or CSS preprocessor data spritesheettemplates CircleCI(https://c...

    1 年前
  • sg-templates

    Templates for SUGOS sgtemplates ========== Build Statusbdtravisshieldurlbdtravisurl npm Versi...

    2 个月前

官方社区

扫码加入 JavaScript 社区