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

fthtml

v5.1.0

Published

An HTML preprocesser built to cut down on special characters/tags and typing. Incorporates importing other .ftHTML files, basic variables and is not whitespace specific. Includes a CLI

Downloads

15

Readme

ftHTML is an HTML preprocessor created to simplify regular HTML markup and get rid of all the unnecessary typing needed for tags, selectors and special characters. The focus is on importing basic templates, utilizing limited variables and generating a more modularized project. Included is a CLI that helps make this transition easier by quickly converting ftHTML files to static resources you can upload to any server like normal.

Visit https://www.fthtml.com for more information and resources

Quickly build HTML resources without the limitations of HTML

STOP DOING THIS FOR COMMON BOOTSTRAP MARKUP:

<button type="button" class="btn btn-primary btn-sm">Primary</button>
<button type="button" class="btn btn-secondary btn-sm">Secondary</button>
<button type="button" class="btn btn-success btn-sm">Success</button>
<button type="button" class="btn btn-danger btn-sm">Danger</button>

<button type="button" class="btn btn-link btn-sm">Link</button>

AND DO THIS WITH FTHTML:

//tiny templates are known as aliases
#tinytemplates
  btn button(type=button .btn .btn-sm)
#end

btn(.btn-primary)   "Primary"
btn(.btn-secondary) "Secondary"
btn(.btn-success)   "Success"
btn(.btn-danger)    "Danger"

btn(.btn-link) "Link"

The above ftHTML snippet produces the same HTML as above, but in a more readable, customizable, friendly-to-use, reusable and modular manner.

Features

  • if-elif-else decision tree and control flow
  • for-each control flow
  • Aliases
  • Variables and global variable support
  • Template and property binding
  • Import other files natively
  • Native JSON support
  • Macros like __DATE__, __NOW__, __JS_URI__
  • Functions like choose, html_encode, html_decode, random, replace, str_repeat, str_reverse, str_format, substring, tcase, trim
  • String interpolation
  • Embedded Languagues
  • Easy typing
  • Selector syntax sugar - use # for attribute ids and . for classes
  • In depth vscode extension support

For a more complete HTML example - Turn this:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
  <link rel="stylesheet" href="styles.css"/>
</head>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<img src="img_typo.jpg" alt="Girl with a jacket">
<p style="color:red">I am a paragraph</p>
<ul id="myList" class="drinks" data-drinktypes="morning">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
</body>
</html>

Into ftHTML:

doctype "html"
html
{
  head
  {
    title "Page Title"
    link(rel=stylesheet href=styles.css)
  }
  body
  {
    h1 "My First Heading"
    p "My First Paragraph"

    img(src=img_typo.jpg alt="Girl with a jacket")

    p (style="color:red") "I am a red paragraph"

    ul (#myList .drinks data-drinktypes=morning) {
      li "Coffee"
      li "Tea"
      li "Milk"
    }
  }
}

You can import other ftHTML files by simply using the import keyword. That way you only have to write markup once and use it anywhere! The following demonstrates importing a footer tag:

html
{
  import "header"
  body
  {
    ...
  }
  import "footer"
}

Imported files must use ftHTML syntax.

You can dynamically generate content based on conditions or import scenarios but here is a brief example of how to use our #if-elif-else directives to dynamically load content based on a given expression:

#if @pageTitle contains "home"

  h1 "Hello World"

#elif @pageTitle contains "contact"

  h1 "Contact Me"
  import "./contact-form"

#elif @pageTitle contains "about"

  h1 "About Me"
  import "./about"

#end

Installing

npm:

It is recommended to install ftHTML globally to take advantage of the CLI.

For those that don't know, installing globally allows you to use the module in any directory of your computer. This makes it easier to convert files to static resources, process tasks for IDE's and more.

npm install -g fthtml

Using

Node.js:

const ftHTML = require('fthtml');
ftHTML.renderFile('filename')
      .then(html => console.log(html))
      .catch(console.log);
  • .fthtml extn is intended to be omitted from the filename.
  • .renderFile() returns the interpreted HTML syntax
  • Alternatively, you can just compile text with ftHTML.compile(text) if you don't want to use a file

Additionally, you can convert .fthtml resources via command line and export them as static resources.

Roadmap can be found here