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

jqfy

v1.4.4

Published

Convert html to js function

Downloads

25

Readme

jQfy

npm version Dependencies Downloads Gitter(https://badges.gitter.im/Join Chat.svg)

Compiles in server, Render in browser. online demo, examples

Install

$ npm install -g jqfy

Usage

Complie htmls

$ mkdir templates/
$ vim templates/well.html # write your sub html
$ jqfy -i templates/ -o js/templates.js

Use in browser:

<script src="js/jquery.min.js"></script>
<script src="js/templates.js"></script>
<script>
    $('body').append(templates.well())
</script>

help

$ jqfy -h
  
  Usage: jqfy [options]

  Options:

    -h, --help                   output usage information
    -V, --version                output the version number
    -i, --input [path]           source file or directory (default: .)
    -o, --output [path]          destination file
    -r, --return-type [type]     choice return type (root|contents|html)
    -e, --ext [ext]              extensions (default: html)
    -n, --namespace [namespace]  namespace (default: templates)
    --fix-return-type            fix return type of generated function
    --return-object              return object, output in $ property of object
    --use-shortcut-functions     use shortcut functions in generated function
    --use-getter                 use getter/escape functions in generated function
    -T, --no-trim                do not trim
    -C, --no-comment             ignore comments

Custom tags and attributes

script tag

We write content of script tags to body of function. if src attribute exists, content ignored.

attributes

  • src: script path

jqfy:name attribute

With this attribute you can set variable name.

{{val}} in text or attribute name and value

render value of data.val in the output html.

note: in attribute name use {{var}} without space. for example {{ x }} not supported in attributes name

example

input html:

<div id="div-{{ i }}" class="text-{{ type }}" data-{{k}}="{{ v }}">
    {{i}}: {{ text }}
</div>

use:

render({
  i: 5,
  type: 'info',
  k: 'target',
  v: '#form-1',
  text: 'Hi jQfy'
}, {returnType: 'html'})

output:

<div id="div-5" class="text-info" data-target="#form-1">5: Hi jQfy</div>

How it works

First we parse your html with cheerio then foreach tag generate a code. This code create a jquery object and set id, class and attributes of element, then append jquery object to parent's jquery object. if script tags exist in your html, we append content of script to generated code.