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

jquery-tmpl-convert

v1.0.1

Published

Application is created to help in migration from deprecated jQuery template library. Application is able to converte jQuery template to handlebar templates. Application supports two working modes: command-line interface(CLI) and server preview for interac

Downloads

27

Readme

jquery-tmpl-convert

Application is created to help in migration from deprecated jQuery template library. Application is able to converte jQuery template to handlebar templates. Application supports two working modes: command-line interface(CLI) and server preview for interactive template converting. If needed application can be extended to convert other template types.

Installing

To install package globally run command:

npm install jquery-tmpl-convert -g

If you need to use package API install it locally running command:

npm install jquery-tmpl-convert --save

Running application using command-line interface (CLI)

Without server

To convert source jQuery template files into handlebar templates run command:

jquery-tmpl-convert --files <path_to_source_templates> --output <output_directory>

where <path_to_source_templates> is glob to source jQuery template files and <output_directory> is directory where converted handlebars files will be copied. The output directory will also contain report.txt file that contains info, warning and error messages for each converted template.

Example:

jquery-tmpl-convert --files /my_templates/*.htm --output /converted_tmp/

With server

To run jquery-tmpl-convert application in server mode execute command:

jquery-tmpl-convert --files <path_to_source_templates> --server

After command executes open browser and enter address http://localhost:3000. UI provides preview of all original and converted templates. Use UI to edit converted templates using double click on any converted template. Templates can be downloaded via "Download" button. Example:

jquery-tmpl-convert --files /my_templates/*.htm --server

CLI arguments

Usage:

jquery-tmpl-convert [options]

Options:

| Command | Short flag | Description | | -----------------------------|------------------|-------------| | --files <globs> | -f <globs> | input files glob for jquery templates to convert (default: ./.(html),./.(htm)) | | --output [path] | -o [path] | output directory for converted files (default: ./results) | | --server | -s | run application is server mode | | --port <n> | -p <n> | server port (default: 3000) | | --converter <id> | -c <id> | id of the target converter (default: hbs) | | --extension <extension>| -e <extension> | ffile extension of converted templates (default: define by chosen converter) | | --help | -h | output usage information | | --version | -V | output the version number |

Using API

If application is installed locally it can be run using API. In order to run application from code follow next example:

	const { Application } = require('jquery-tmpl-convert');

	// create application configuration
	const config = {
		// start the application using server mode
		server: true,
		files: ['./**/*.html'],
		output: '',
		port: 3000,
		converter: 'hbs',
		extension: '.hbs'
	};

	const app = new Application(config);
	app.start();

Extend application with custom template converter

Example how to write your custom template converter:

	const { Application,
			Converter,
			// helper functions
			Utils,
			// application models
			Models
	} = require('jquery-tmpl-convert');

	// define custom converter
	class MyCustomConverter extends Converter {
		get id() {
			return 'myCustomConverter';
		}

		get name() {
			return 'My custom converter';
		}

		get fileExtension() {
			return 'htm';
		}

		constructor(cfg) {
			super(cfg);
		}

		convert(templates) {
			// TODO convert jQueryTemplates, see HandlebarsConverter.js for more details

			this._convertTemplates;.push(/* Push template after it is converted */);
		}
	}

	// create application configuration
	const config = {
		// start the application using server mode
		server: true,
		files: ['./**/*.html'],
		output: '',
		port: 3000,
		converter: 'hbs',
		extension: '.hbs'
	};

	const app = new Application(config);
	app.start([new MyCustomConverter()]);

Running the tests

Use command below to run test locally:

npm run test

License

This project is licensed under the MIT License - see the LICENSE.md file for details