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-ractive-parse

v1.3.5

Published

Pre-parse Ractive templates for use in ExtJS or other MVC projects

Downloads

9

Readme

grunt-ractive-parse

Pre-parse Ractive templates for use in ExtJS or other MVC projects

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-ractive-parse --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-ractive-parse');

The "ractive_parse" task

Overview

In your project's Gruntfile, add a section named ractive_parse to the data object passed into grunt.initConfig().

grunt.initConfig({
  ractiveparse: {
    options: {
      // Task-specific options go here.
    },
    // Your src directory goes here. 
    // If you have more than one direcotry or want to specify specific files use this syntax ['/one', 'two.html']
    src: '', 

    // Your destination file goes here. Note: you may have only one destination file for each ractive_parse
    dest: ''
  },
});

Options

options.appName

Type: 'String' Default value: NA

A string value that is used set the name of the app. Note: this field is required if you use the 'extjs' type

options.type

Type: String Default value: 'javascript'

A string value that is used to identify the syntax of the parsed templates file. Options are 'javascript' || 'extjs'

options.ignorePath

Type: String Default value: ''

A string value path that is used to identify folder names to skip when creating the ExtJS class name.

options.clsConfig

Type: Object Default value: ''

An object to allow you to set custom properties on your final compiled templates file.

Usage Examples

Default Options

In this example, the default options are used to parse the templates directory. This will loop through all folders in the templates directory and create a single templates javascript file of pre-parsed Ractive templates.

grunt.initConfig({
  ractiveparse: {
    options: {},
    src: 'templates/*',
    dest: 'code/templates.js'
  },
});

Custom Options

In this example, custom options are used to do set the final javascript template file as an Sencha ExtJS class. The appName must match the name of your ExtJS applicaiton. The class path will automatically be set using the appName + the path to your final destination template.

Example

Gruntfile.js

grunt.initConfig({
  ractiveparse: {
    options: {
      appName: 'MyApp',
      type: 'extjs',
      ignorePath: 'app/',
      configCls: {
        singleton: true
      }
    },
    src: 'templates/*',
    dest: 'app/templates/templates.js'
  },
});

File Structure

MyApp/
  |- index.html

  |- app/
    |- templates/

  |- templates/
    |- temp1.html
    |- temp2.html
    |- one/
      |- onetemp1.html
      |- onetemp2.html

MyApp/app/templates/templates.js

Ext.define('MyApp.templates.Templates', {
  
  singleton: true,

  templates: {
    temp1 : [{"t":7,"e":"div","a":{"class":"box"},"f":[{"t":2,"x":{"r":["box","content"],"s":"${0}-${1}"}}]}],
    temp2 : [{"t":7,"e":"button","a":{"class":"btn"},"f":[{"t":2,"x":{"r":["button","label"],"s":"${0}-${1}"}}]}],
    one: {        
        onetemp1 : [{"t":7,"e":"div","a":{"class":"box"},"f":[{"t":2,"x":{"r":["box","content"],"s":"${0}-${1}"}}]}],
        onetemp2 : [{"t":7,"e":"button","a":{"class":"btn"},"f":[{"t":2,"x":{"r":["button","label"],"s":"${0}-${1}"}}]}]
    }
  }
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Use the .editorconfig file associated with this project and add unit tests for any new or changed functionality. Lint and test your code using Grunt and grunt-contrib-jshint. Please see the Contributing to grunt guide for information on contributing to this project.

Release History

  • 2014-05-16   v0.1.0   Initiated project.
  • 2014-05-16   v1.0.0   Initial release of project.
  • 2014-05-16   v1.2.0   Published to NPM
  • 2014-05-16   v1.3.0   Added additional build options