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

sails-hook-bem-render

v2.0.0

Published

BEM template engine for Sails app

Downloads

11

Readme

Build Status GitHub Release

BEM template render for Sails js

  • BEM: http://bem.info
  • Sailsjs: http://sailsjs.org

Install NPM version

(sails >= 0.11)

  • add this hook to package.json: npm i sails-hook-bem-render --save
  • use in your controllers res.render(data)

(sails < 0.11) also needs explicit hooks declaration:

  • create bem-render folder in api/hooks
  • create index.js file in api/hooks/bem-render/
  • write in api/hooks/bem-render/index.js this:
   module.exports = require('sails-hook-bem-render');

Usage

For example project see sails-bem-project-stub.

  1. Create a /views/common directory for BEM blocks.
  2. Create /views/.enb directory with make-config file for enb assembler. You can copy config from sails-bem-project-stub/frontend/.enb/make.js. Notice: there is only desktop config yet.
  3. Create /views/desktop.bundles/index/index.bemdecl.js file – dependency declaration for enb assembler:
exports.blocks = [
    {block: 'page'} // Other dependencies will be declare in `page` block.
];
  1. Add dependencies: 4.1 npm dependency for BEM and enb to package.json:
  "dependencies": {
    "vow": "^0.4.5",
    "ym": "^0.1.0"
  },
  "devDependencies": {
    "bem": "^0.9.0",
    "borschik": "^1.3.0",
    "borschik-tech-cleancss": "^1.0.0",
    "bower": "^1.3.9",
    "enb": "^0.13.7",
    "enb-autoprefixer": "^0.1.1",
    "enb-bem": "0.1.0-beta2",
    "enb-bemxjst": "^1.3.2",
    "enb-borschik": "^1.1.1",
    "enb-diverse-js": "^0.1.0",
    "enb-modules": "^0.2.0",
    "enb-stylus": "1.1.2"
    }

4.2 bower:

  "dependencies": {
    "bem-core": "2.6.0"
  }

Don't forget to add .bowerrc file:

{
    "directory": "views/libs"
}
  1. After you add your blocks, run node_modules/.bin/enb make -d views --no-cache. It will compile BEMTREE, BEMHTML, assemble js, CSS into views/desktop.bundles/merged folder.
  2. So, in BEMTREE-template page block you can access data by this.ctx.data. NB: you can find req (req.session, req.path and other useful stuff) object in this.ctx.data.req.