1.0.0 • Published 10 years ago

mshc1 v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
10 years ago

meteor-static-html-compiler

A tool that allows you to compile static HTML templates so you could import them from a module.

Installation

meteor add urigo:static-html-compiler

If you are looking for a package with a working implementation of this tool you should check static-templates.

Example

import {
  MainHtmlCompiler, // body, head
  TemplateHtmlCompiler, // templates
  StaticHtmlCompiler,
  utils,
} from 'meteor/urigo:static-html-compiler';

class TemplateCacheCompiler extends TemplateHtmlCompiler {
  compileContents(file, contents) {
    const template = utils.clean(contents);
    return `module.exports = "${template}"`;
  }
}

Plugin.registerCompiler({
  extensions: ['html']
}, () => new StaticHtmlCompiler(new MainHtmlCompiler, new TemplateCacheCompiler));

API

StaticHtmlCompiler

Compiles a html file to a string by default

constructor(MainHtmlCompiler?, TemplateHtmlCompiler?)

It is possible to change the way StaticHtmlCompiler works by providing custom MainHtmlCompiler and TemplateHtmlCompiler.

MainHtmlCompiler

Handles files that contain <head/> or <body/> tag.

TemplateHtmlCompiler

Handles files that do not contain <head/> and <body/> tags.

compileContents(file, contents: string): string

Returns contents of a ES6 module that will be later compiled from a string to JavaScript code.

utils

clean (html: string): string

Cleans up HTML.

minify (html: string): string

Minifies HTML.

1.0.0

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago