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-data-injector

v0.0.2

Published

Grunt Task that uses the git diff information to modify the content of files

Downloads

3

Readme

grunt-data-injector

"Grunt Task that injects data into source.",

A simple Grunt multitask that injects data into source code. e.g. JSON in js. Useful when you need static data simultaneously in a markup template and source code.

Table of Contents

Getting Started

Use it with grunt

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-data-injector

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-data-injector');

Documentation

Example

Assume you have the following file structure:

data\
  somefile.json
  subdir\
    anotherfile.json
js\
  somefile.js
  subdir\
    anotherfile.js

than this task

dataInjector:
  options:
    # change options on global level
  compile:
    options:
      # change options on task level
    files: [
      expand: true,
      cwd: "data/",
      src: ["**/*.json"],
      ext: ".js",
      dest: "js/"   
    ]

would inject the data from the .json files into the corresponding .js files.

Options

Here the available options with the corresponding defaults:

# name of the reader - currently `json` or `yaml` available
source: "json"

# name of the formatter - currently only `js` available
target: "js"

# a dot-separated path to select data from the json prior injecting.
path: ""

# only in conjunction with path. Keeps the structure of the selected data if set.
keepStructure: true

# function which will take a filename and return a js object, used to read the data.
reader: grunt.file.readJSON

# string, after which the data will be injected.
inserter: "{"

# function which takes the data and returns a string ready for injection
formatter: (data,returnType,filename) ->
  formattedData = [returnType+"  // content from "+filename+returnType]
  for k,v of data
    formattedData.push "  var "+k+" = "+util.inspect(v,{depth:null})+";"+returnType
  formattedData.push "  // end of content from "+filename
  return formattedData.join("")

Extensions

If you build your own reader or formatter, I would be happy to include them!

Release History

  • v0.0.2: Added support for yaml
  • v0.0.1: First Release

License

Copyright (c) 2014 Paul Pflugradt Licensed under the MIT license.