npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jade-pages-brunch

v2.0.0

Published

Adds Jade static pages support to brunch.

Downloads

16

Readme

jade-pages-brunch

Adds Jade static pages support to brunch.

This plugin compile Jade templates into their HTML representation and create separate file for each input source file without wrapping it in AMD/CommonJS modules.

Usage

Install the plugin via npm with npm install --save jade-pages-brunch.

Or, do manual install:

  • Add "jade-pages-brunch": "x.y.z" to package.json of your brunch app.
  • If you want to use git version of plugin, add "jade-pages-brunch": "git+https://github.com/Kagami/jade-pages-brunch.git".

Brunch plugin settings

Plugin settings could be defined in the plugins.jadePages section of the brunch config. Defaults are:

exports.config =
  ...
  plugins:
    jadePages:
      destination: (path) ->
        path.replace /^app[\/\\](.*)\.jade$/, "$1.html"
      jade:
        doctype: "html"
      htmlmin: false

Pattern

You could compile only certian Jade pages by specifying pattern option. By default all files with jade extension are compiled.

Example:

exports.config =
  ...
  plugins:
    jadePages:
      pattern: /^app\/pages\/.*\.jade$/

Destination

You could specify custom place for compiled Jade pages via destination option. It should be Function which takes path of the source file and return destination file path String (relative to the public path). All intermediate directories in the path are created automatically.

By default all Jade pages in app/ are compiled to public/ with the same directory structure and have html extension.

Jade options

You could specify Jade options and template locals in the jade and jade.locals sections accordingly. Example:

exports.config =
  ...
  plugins:
    jadePages:
      jade:
        doctype: "xml"
        pretty: true
        locals:
          varname: "123"

Jade filters

You could specify Jade filters in the filters section. Example:

exports.config =
  ...
  plugins:
    jadePages:
      filters:
        php: (text) -> '<?php \n' + text + '\n?>'
      destination: (path) ->
        path.replace /^app[\/\\](.*)\.jade$/, "$1"

test.php.jade:

:php
  // ...
  $answer = 42;
  // ...

doctype html
html(lang="de")
  body
    p It's <?= $answer ?>!

Output (test.php):

<?php
// ...
$answer = 42;
// ...
?>
<!DOCTYPE html>
<html lang="de">
  <body>
    <p>It's <?= $answer ?>!</p>
  </body>
</html>

HTML minification

You could minify compiled templates using html-minifier by passing following values to the htmlmin section:

  • Enable with default options with true. Default options are:
removeComments: true
removeCommentsFromCDATA: true
removeCDATASectionsFromCDATA: true
collapseBooleanAttributes: true
useShortDoctype: true
removeEmptyAttributes: true
removeScriptTypeAttributes: true
removeStyleLinkTypeAttributes: true
  • Specify custom options by passing Object; see options description here.

Note that by default HTML minification is disabled and using minification with agressive options could break things.

Example:

exports.config =
  ...
  plugins:
    jadePages:
      htmlmin:
        removeComments: true
        collapseWhitespace: true
        removeEmptyAttributes: true

FAQ

Why do you need yet another Jade plugin for Brunch?

Because static-jade-brunch and jaded-brunch don't compatible with another plugin which I use, jade-ngtemplates-brunch. They are both using templates brunch option and enter into a conflict with each other.

And I don't want to implement jade-pages functionality as a part of jade-ngtemplates-brunch (like it was done for example in jade-angularjs-brunch) because it contradicts with plugins modularity spirit.

Then move htmlmin feature inside the separate optimizer plugin.

Unfortunately Brunch doesn't provide a lot of flexibility for plugins. From it's point of view templates are always compiled into single JS file so we need to hack it out and write resulting compiled pages by ourself. Since we did it, another plugin wouldn't make any sense.

In this issue goes discussion about Brunch architecture improvements but no real progress is done for now.

License

jade-pages-brunch - Adds Jade static pages support to brunch

Written in 2014 by Kagami Hiiragi [email protected]

To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.

You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.