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

@satvik2101/lucid

v0.1.1

Published

A (one of many) HTML templating engine that produces static HTML files. At it's core it's a new way to write HTML.

Downloads

1

Readme

lucid

A (one of many) HTML templating engine that produces static HTML files. Based entirely on TypeScript. At it's core it's a new way to write HTML.

<a href="www.google.com" rel="nofollow" target="_blank">Google</a>

becomes


new A().href("www.google.com").rel("nofollow").target("_blank").populate("Google")

The populate function is used to set the children of the tag. It takes an array of strings or tags, or a mixture. It can also take a single string or tag.

You can also use the shorthand p function to populate the tag.

The toString() function will return the HTML string.

All the HTML tags have been implemented as subclasses of the parent class Tag.

Examples

Basic

import A from "./tags/A";

const a = new A().href("www.google.com").rel("nofollow").target("_blank").p("Google")

console.log(a.toString())

Nesting


import A from "./tags/A";
import Div from "./tags/Div";

const div = new Div().class("link-container").populate(
    new A().href("www.google.com").rel("nofollow").target("_blank").p("Google"),
    new A().href("www.github.com").rel("nofollow").target("_blank").p("Github")
)

console.log(div.toString())

Nesting with text


import A from "./tags/A";
import Div from "./tags/Div";

const div = new Div().class("link-container").populate(
    new A().href("www.google.com").rel("nofollow").target("_blank").p("Google"),
    "This is some text",
    new A().href("www.github.com").rel("nofollow").target("_blank").p("Github")
)

console.log(div.toString())

There are also some convenience tags that make using them easier. For example, the EnhancedDiv class takes arguments for class, id, and content. Similarly, the EnhancedImg,EnhancedScript,SimpleAnchor tag provide convenience methods for common attributes.

Example for EnhancedDiv:

import EnhancedDiv from "./urils/EnhancedDiv";

const div = new EnhancedDiv({
    id:"my-id",
    class:"my-class",
    children:[
        "This is some text",
        new A().href("www.google.com").p("Google"),
    ]
})


While most attributes listed in the MDN docs have their own functions, if there's an attribute that doesn't have a function, you can use the setAttr function to set it.

import A from "./tags/A";

const a = new A().setAttr("data-foo","bar").p("Google")

For a more comprehensive example, see the website branch of this repo. It uses Lucid to generate the code for my website

You can also view the Website code here. But that also contains other stuff (AWS stuff and other things) that you might not want to see.