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

@settlin/spacebars-loader

v1.0.9

Published

blaze templates loader for meteor-webpack

Downloads

476

Readme

spacebars-loader

Inspired from https://github.com/xamfoo/spacebars-loader A plugin for webpack to compile Spacebars templates for running on a Meteor platform. It can be used with https://github.com/ardatan/meteor-webpack to use blaze templates.

Installation

meteor npm install spacebars-loader --save-dev
meteor remove blaze-html-templates aldeed:template-extension spacebars-compiler standard-app-packages
meteor add spacebars blaze underscore

Basically, since ardatan:meteor-webpack is itself a registered as an html compiler, we can not use the blaze-html-templates package, which is dependent on the compiler templating. Instead we ask webpack to use this loader and compile the templates into required Template.<name>.

Usage

webpack.config.js

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.html$/,
        loader: 'spacebars-loader'
      }
    ]
  }
};

Initialize Template

Since we are not using templating, we do not have direct access to Template. We can enable this by doing,

window.Template = Blaze.Template;

as the very first line of our client entry file.

That's it. Now all your templates should work.

Extra (Optional) Usage

Query options

  • attachGlobal (default=true)
    • Don't attach template to Template object if false
    • Example: spacebars-loader?attachGlobal=false

Output

The loader compiles a Spacebars template

<template name='myTemplate'>
  <div>
    <h1>My Template</h1>
  </div>
</template>

to a Meteor compatible output:

module.exports.template = new Blaze.Template("Template.myTemplate", (function () {
  var view = this; return HTML.DIV("\n    ", HTML.H1("My Template"), "\n  ");
}));
Blaze.Template.__checkName("myTemplate");
Blaze.Template["myTemplate"] = module.exports.template;

The exports allow you to use it in a JS file like this:

import {template} from './myTemplate.html';

template.onCreated(function () {
  console.log('Created a template!');
});