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

handlebars-helper-less

v0.1.1

Published

{{less}} handlebars helper. This helper allows you to use LESS inside style tags in your HTML. By default, the resulting CSS will be rendered inside the `<style>...</style>` tags of the rendered HTML, but you may alternatively define a destination path us

Downloads

12

Readme

{{less}} NPM version

{{less}} handlebars helper. This helper allows you to use LESS inside style tags in your HTML. By default, the resulting CSS will be rendered inside the <style>...</style> tags of the rendered HTML, but you may alternatively define a destination path using the dest hash option of the helper.

Quickstart

In the root of your project, run the following in the command line:

npm i handlebars-helper-less --save-dev

Example:

{{#less}}
<style>
@foo-border-color: #eee;

// Foo
.foo {
  margin: 20px 0;
  padding: 20px;
  border-left: 3px solid @foo-border-color;
}
</style>
{{/less}}

Compiles to:

<style>
.foo {
  margin: 20px 0;
  padding: 20px;
  border-left: 3px solid #eee;
}
</style>

Options

In addition to native Less.js options, the following helper options may be defined on the less object in the assemble options, e.g:

assemble: {
  options: {
    less: {
      // less options here
    }
  }
}

dest

Type: String Default: undefined

Optionally define a destination path for the compiled CSS. The filename will be appended to either a destdir defined in the less options, or to the assets path, if defined. When no dest is defined in the hash, the resulting CSS will be rendered inside <style>...</style> tags in the output HTML.

For example, give the following expression: {{#less dest="foo.css"}}...{{/less}}, and the following defined in the Gruntfile:

assemble: {
  options: {
    assets: 'dist/assets/css'
  }
}

The compiled CSS will be saved to: dist/assets/css/foo.css.

destdir

Type: String Default: undefined

Optionally define a destination directory to prepend to any dest used in the options hash of the helper.

For example, give the following expression: {{#less dest="foo.css"}}...{{/less}}, and the following defined in the Gruntfile:

assemble: {
  options: {
    assets: 'dist/assets/css',
    less: {
      destdir: 'css'
    }
  }
}

The compiled CSS will be saved to: css/foo.css.

Usage Examples

Using the dest option

HTML and LESS

Given that we have component.hbs:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>

    {{#less dest="component.css"}}
      <style>
      @component-border-color: #eee;
      .component {
        margin: 20px 0;
        padding: 20px;
        border-left: 3px solid @component-border-color;
      }
      </style>
    {{/less}}

    <!-- The component -->
    <div class="component">This is an awesome component!</div>

  </body>
</html>

And we have this config in the Gruntfile:

assemble: {
  options: {
    assets: 'dist/assets/css'
  }
}

Rendered HTML and CSS

It would render to: dist/component.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>

    <!-- The component -->
    <div class="component">This is an awesome component!</div>

  </body>
</html>

and dist/assets/css/component.css

.foo {
  margin: 20px 0;
  padding: 20px;
  border-left: 3px solid #eee;
}

Register the Helper

If you use Assemble choose one of the following approaches to register the helper:

Option #1: Gruntfile

Define paths to any helpers in the helpers option of your project's Gruntfile:

grunt.initConfig({
  assemble: {
    options: {
      helpers: ['handlebars-helper-less']
    },
    files: {}
  }
});

Option #2: Add to devDependencies and keywords

Or, add the helper to the devDependencies of your project's package.json, and then add the name of the module, handlebars-helper-less, to the keywords:

{
  "name": "foo",
  "dependencies": {
    "handlebars-helper-less": "*"
  },
  "keywords": [
    "handlebars-helper-less"
  ]
}

Assemble will automatically register any helpers found when matching names are defined in both keywords and devDependencies. It just works.

Contributing

Please see the Contributing to Assemble guide for information on contributing to this project.

Author

Jon Schlinkert

Related Projects and Links

License

Copyright (c) 2013 Jon Schlinkert, contributors. Released under the MIT license


This file was generated by grunt-readme on Fri Nov 15 2013 01:02:26.