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

regularify

v0.3.0-pre

Published

a browserify transform for regularjs

Downloads

20

Readme

a browserify transform for regularjs

install

npm install regularify

build script



var path = require("path");
var fs = require('fs');

var regularify = require('../');
var browserify = require('browserify');


return browserify([path.join(__dirname, './src/index.js')])
  .transform(regularify({
    BEGIN: '{', 
    END: '}',
    rglExt: ["txt"]
  }))
  .bundle()
  .on("error", function(err){
    throw err
  })
  .pipe(fs.createWriteStream( path.join(__dirname ,"./bundle.js")))

transforms

1.rgl

rgl preparse a text string to Regularjs's AST.

file:test.rgl

<div>{hello}</div> 
{#list list as item}
  <h2>{item}</h2>
{/list}
<div class="col-sm-2">
  content body
</div>

will be converted to

module.exports = [{"type":"element","tag":"div","attrs":[],"children":[{"type":"expression","body":"_c_._sg_('hello', _d_, 1)","constant":false,"setbody":"_c_._ss_('hello',_p_,_d_, '=', 1)"}]},{"type":"text","text":" \n"},{"type":"list","sequence":{"type":"expression","body":"_c_._sg_('list', _d_, 1)","constant":false,"setbody":"_c_._ss_('list',_p_,_d_, '=', 1)"},"variable":"item","body":[{"type":"text","text":"\n  "},{"type":"element","tag":"h2","attrs":[],"children":[{"type":"expression","body":"_c_._sg_('item', _d_, 1)","constant":false,"setbody":"_c_._ss_('item',_p_,_d_, '=', 1)"}]},{"type":"text","text":"\n"}]},{"type":"text","text":"\n"},{"type":"element","tag":"div","attrs":[{"type":"attribute","name":"class","value":"col-sm-2"}],"children":[{"type":"text","text":"\n  content body\n"}]}];

rglc

rglc precompile a html fragment to Regularjs's Component.

Example

file: test.rglc

<div>{hello}</div> 
{#list list as item}
  <h2>{item}</h2>
{/list}
<div class="col-sm-2">
  content body
</div>


<script>

var Regular = require("regularjs");

module.exports = Regular.extend({
  template: template
})

</script>

will be converted to

var template=[{"type":"element","tag":"div","attrs":[],"children":[{"type":"expression","body":"_c_._sg_('hello', _d_, 1)","constant":false,"setbody":"_c_._ss_('hello',_p_,_d_, '=', 1)"}]},{"type":"text","text":" \n"},{"type":"list","sequence":{"type":"expression","body":"_c_._sg_('list', _d_, 1)","constant":false,"setbody":"_c_._ss_('list',_p_,_d_, '=', 1)"},"variable":"item","body":[{"type":"text","text":"\n  "},{"type":"element","tag":"h2","attrs":[],"children":[{"type":"expression","body":"_c_._sg_('item', _d_, 1)","constant":false,"setbody":"_c_._ss_('item',_p_,_d_, '=', 1)"}]},{"type":"text","text":"\n"}]},{"type":"text","text":"\n"},{"type":"element","tag":"div","attrs":[{"type":"attribute","name":"class","value":"col-sm-2"}],"children":[{"type":"text","text":"\n  content body\n"}]}];

var Regular = require("regularjs");
module.exports = Regular.extend({
  template: template
})

rglc will inject a variable named template for you which represent the html in same file.

rglc exports a standard Regular Component.

option

  1. BEGIN: the BEGIN_TAG for regularjs template, the default is "{"
  2. END: the END_TAG for regularjs template, the default is "}"
  3. rglExt: the custom extension for regularjs's template, the DEFAULT is ['rgl']. passed extensions will concat with DEFAULT EXTENSIONS
  4. rglcExt: the custom extension for regularjs's component, the DEFAULT is ['rglc']. passed extensions will concat with DEFAULT EXTENSIONS

see the https://github.com/regularjs/regularify/tree/master/example folder for help