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

grunt-embrace

v0.0.10

Published

Template adapter to render and compile Mustache, Handlebars, Dust and Swig templates

Downloads

34

Readme

embrace

Embrace is an adapter that provides a standalone api for rendering and compiling templates. An additional grunt task is also exposed.

Embrace helps compile and render templates, with or without a data context, register partials, and copy browser side libraries in to place.

Engines

Mustache

Mustache is a mature and robust template language. Its simple syntax and logic-less nature is perfect for short tasks.

Handlebars

As an extension of mustache, it provides a bit more, but maintains the syntax.

Dust

right now, Dust is unusable in modern versions of Node because this line throws

Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead

the related issue is a whole year old now but linkedin picked up the project and their fork seems to be even better and improved than the original

Swig

Swig is a powerful template language with a lot of features that are really useful, but hard to find in other engines. Such as template inharitance.

API

Doc coming soon.. until then, the source is commented where it's applicable.

Grunt task

options

options.client

Type: String

Default: ""

A directory path where to copy the client side embrace script.

options.dust.client

Type: String

Default: ""

A directory path where to copy the dust client side library.

options.render

Type: Boolean

Default: true

Render files with the given context.

options.compile

Type: Boolean

Default: false

Precompile files into javascript.

options.data

Type: String

Default: ""

A globbing pattern that collects *.json files.

These will be merged into a global context and will be passed to each template. The file names will be used for root field names.

options.resolve

Type: String

Default: ""

The path part that will be ignored when looking up partials.

If you match partials "nested/folder/partials/*.mustache" you would have to refer partials in your templates with their full path: {{>nested/folder/partials/apartial}} With this option, you can set a path part that will be excluded from partial resolution. E.g. partialsRoot: "nested/folder/partials/". Now you can just refer to templates as {{>apartial}}

options.partials

Type: String

Default: ""

A globbing pattern that collects template files. The pattern is relative to the resolve options.

Include/import/partial paths will be looked among these files.

options.cache

Type: Boolean

Default: false

Embrace loads template files once and returns the same content every time it is requested if this option is true. False by default, because the main reason of this module is to use it with a watch task.

options.setup

Type: Function

Default: null

A function receiving the template adapter and the embrace object setup(Adapter adapter, Object embrace)

Compile


  grunt.initConfig({
    embrace: {
      options: {
        client: "test/embrace/",
        data: "test/data/*.json",
        resolve: "test/partials/",
        partials: "**/*.dust",
        cache: false,
        dust: {
          helpers: "",
          client: "test/embrace/"
        },
        setup: function( adapter, embrace ){}
      },
      compileDust: {
        options: {compile: true},
        expand: true,
        cwd: "test/",
        src: ["**/*.dust"],
        dest: "test/compiled/",
        ext: ".js"
      },
      compileAndConcatDust: {
        options: {
          compile: true,
          concat: true
        },
        files: {
          "test/compiled/partials.dust.js": "test/partials/**/*.dust",
          "test/compiled/templates.dust.js": "test/templates/**/*.dust"
        }
      }
    }
  })

Render


  grunt.initConfig({
    embrace: {
      options: {
        client: "test/embrace/",
        data: "test/data/*.json",
        helpers: "test/helpers/dust/*.js",
        resolve: "test/partials/",
        partials: "**/*.dust",
        dust: {
          helpers: "",
          client: "test/embrace/"
        },
        setup: function( adapter, embrace ){}
      }
      renderDust: {
        options: {render: true},
        expand: true,
        cwd: "test/templates",
        src: ["*.dust"],
        dest: "test/rendered/"
      }
    }
  })

Licence

MIT