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

roots-yaml

v0.0.4

Published

Load YAML data files into your roots project.

Downloads

6

Readme

Roots-YAML

npm tests dependencies Coverage Status

Load YAML data files into your roots project.

Note: This project is in early development, and versioning is a little different. Read this for more details.

Why Should You Care?

It's important to maintain clean DRY code. Instead of writing messy and duplicated markup, you can use the power of HTML precompilers and pass data into your templates.

Roots-YAML lets you store your site data in YAML, a human friendly data serialization format and then have that data exposed for you to use in your roots view templates.

Installation

  • make sure you are in your roots project directory
  • npm install roots-yaml --save
  • modify your app.coffee file to include the extension, as such
roots_yaml = require('roots-yaml')

module.exports =
  extensions:
    roots_yaml
      source: 'data'  # default value

Usage

Roots-YAML will look in your source directory and load any .yaml files into a data object for you to use in your views.

Each YAML file will be loaded using js-yaml and have the result set to data.<file_name>.

For example, if I have a directory data structured like this:

data/
  staff.yaml
  clients.yaml
  misc/
    doges.yaml
    manatoges.yaml

Inside my view templates:

data.staff returns the data in data/staff.yaml

data.misc.manatoges returns the data in data/misc/manatoges

View Helper

Roots-YAML also adds a handy view helper to your Roots templates. Inside your views, add the following to insert a script tag setting a global data variable in your JS to your YAML data. You can also pass a string into yaml to change the name of the variable.

!= yaml()
!= yaml('manatoge')

results in:

<script>var data = {"doge":{"wow":"such yaml"}};</script>
<script>var manatoge = {"doge":{"wow":"such yaml"}};</script>

License & Contributing