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

jade2react

v0.3.0

Published

A jade to react compiler

Downloads

26

Readme

jade2react

A jade to react compiler, that lets you build complete react components using the jade template language. It supports almost all features of jade and adds some more functionality to make it even easier to build react components.

installation

jade2react is a registered npm module. So you can install it using the following command: npm install jade2react

features

  • Auto compilation: Just require any .jade file and it gets loaded as JavaScript. Just make sure you have required jade2react first and the module react is available from the jade-file's location.
  • This module provides also a transform function to autocompile .jade files while bundling them with browserify.

changes from 0.2.* to 0.3.*

  • jade2react now supports react 0.14.*
  • jade2react now exports your component directly, instead of a factory for it

notes

  • While the render function is auto generated, you also can define javascript, to be added to your component in script. elements on the indentation level 0. exports represents the object that later gets passed to React.createClass(), so if you define functions on it, the will later be available through this. In here, you also can require other JavaScript modules or React components and even other jade files. See example above.
div
    input(type="button" value="Click Me!" onClick=this.click)
script.
    var somemodule = require("somemodule");

    exports.click = function(){
        somemodule.doSomething();
    }
  • Extends still works! But not only the render function gets extended but the whole component. All properties that are defined in the exports object in the derived component automatically get mixed into the current exports object. So, the following example will still work:

base.jade

div
    block content
script.
    exports.click = function(){
        alert("Clicked!")
    }

component.jade

extends ./base.jade
append content
    div(onClick=this.click)
  • Since React allows you to pass children to a component, I also made this available. Just add an children element where you want your children to be rendered:

list.jade

.list
    h1 Children following
    children

You then can pass the children like you'd expect:

component.jade

.main
    List
        p Child 1
        p Child 2
script.
    var List = require("list.jade");
  • Tag contents are always escaped. So h1 hello <b>world</b> will render as h1 hello &lt;b&gt;world&lt;/b&gt; and not h1 hello <b>world</b>. This is because in react you set either the full contents of a tag as insecure html, or nothing. So while the above example would be no problem, the following actually would be:
div <b>hello</b>
    p world!
  • You can define styles either the normal HTML/Jade way or the react way. The following examples are the same:
div(style="backgroundColor:red")
div(style={backgroundColor:"red"})

License

MPLv2, read LICENSE.md for more information