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

uhc

v2.0.1

Published

the useful html compiler

Downloads

22

Readme

UHC

UHC, the useful html compiler, for when you don't need a javascript framework.

Why?

  • html components.
<import path="./component.html" foo="bar" />
  • variables.
<p>hello ${foo}</p>
  • conditional flow & loops.
  • basic html routing.
  • minimal configration needed.
  • sass, postcss and html-minifier support by default.
  • compiles to raw html.
  • and much much more!

How?

  1. install uhc globally
npm install uhc -g
  1. start a new project
  • use a skeleton uhc app.
uhc init app_name
  • or start from scratch with -g to generate uhc.config.json
  1. run uhc to compile.
  2. run uhc dev to start dev mode

plz create an issue to report any bugs or recommend us features we should add.

thank you for using uhc

Documentation


Config

  • use uhc -g to generate uhc.config.json.
  • by default uhc will look for uhc.config.json in current working directory. use -c to pass a custom path.
  • all other paths in uhc.config.json should be relative to src and build dir accordingly.
  • an example uhc.config.json
{
  "uhc": "<uhc_version>",
  "src_dir": "src",
  "build_dir": "public",
  "template": "template.html",
  "minify": true,
  "css": {
    "autoprefix": true,
    "prefix": "@import \"./global.scss\";",
    "sass": true
  },
  "vars": {
    "foo": "bar"
  },
  "routes": {
    "/": "index.html"
  }
}
  • uhc uses html-minifier to minify output html files.
  • you can pass your own html minifier options. for example
"minify": {
    "minifyCSS": false
}
  • you can pass options to sass in the same way.
  • you can load environment variables with dotenv by setting load property. these will be avaliable as variables.
"load": ["key1","key2"]
  • some functions can be disabled by setting property to false.

| functions | property | | -------------------- | --------- | | variables | vars | | if statments & loops | statments | | comments | comments | | html minifier | minify |

Cli

options

| option | function | | ------ | -------------------------- | | h | help | | g | generate uhc.config.json | | c | load custion config file | | w | watch path | | v | show dependencies verisons |

Commands

Init

  • run uhc init to create a skeleton uhc app.
  • by default it creates a project named uhc-app, run uhc init <name> to pass a name.

Dev

  • run uhc dev and see your site on localhost:8080, uhc will also watch for file changes (using chokidar) in src directory and will recompile and reload the browser (using live-server) on changes.
  • PORT can be passed as environment variable.

Component format

  • stylesheets added using link tag are not compiled.
  • load path for sass is the index file.
  • an example component
<style>
  // css or sass styles
  main {
    color: red;
  }
</style>

<h1>title</h1>
<main>
  <p>some text</p>
  <import path="some other component" />
</main>

Importing

  • import component using import tag.
<import path="./component" />
  • import svg using type attribute.
  • the imported svg can be styled from the parent component.
  • you can pass attributes to svg from th import tag.
  • in this example, svg will get a id attribute.
<import path="./logo.svg" type="svg" id="logo" />

Variables

  • variables can be used by ${} syntax.
  • ${} can perform javascript.
<p>hello ${ foo + "something" }</p>
  • vars can be globally declared from uhc.config.json.
  • setting vars to false will disable vars.
"vars": {
  "foo": "bar"
},
  • vars can be passed to component from import tag.
  • components inherit vars from thier parents.
<import path="./component" foo="bar" />

Conditional Flow

  • (){} syntax become an if statment if input is a boolean.
(10 == n) {
<p>hello world</p>
}
  • else if / else are not supported yet. coming soon.

Loops

  • (){} syntax becomes an loop if input is a number.
(n) {
<p>hello world</p>
}

Routes

  • Routes are used to compile diffrent html files.
"routes": {
  "/": "index.html",
  "project": {
    "/": "project.html",
    "table": "table.html"
  },
  "settings": "settings.html"
}

| url | html | | ------------------------------ | ------------- | | website.com/ | index.html | | website.com/project/ | project.html | | website.com/project/table.html | table.html | | website.com/settings.html | settings.html |

  • Directory structure it creates.
build/
├── index.html
├── project
│   ├── index.html
│   └── table.html
└── settings.html

Template

  • template are used share code across diffrent routes.
  • templates must have a body and head tag where compiled code is injected.
  • templates itself will not be compiled.
  • compiled code will replace %head% & %body% respectively.
"template":"template.html",
  • an example template
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="./icon.png" />
    <link rel="stylesheet" href="./global.css" />
    <title>Website</title>
    %head%
  </head>
  <body>
    %body%
  </body>
</html>