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

pug-element-loader

v0.0.7

Published

A loader that converts pug mixin blocks into custom elements for web components.

Downloads

3

Readme

pug-element-loader

npm version

A loader that converts pug mixin blocks into custom elements for web components.

⚠ Caution ⚠

This is an experimental implementation and should not be used in a production environment.
I accept no liability whatsoever.

Usage

$ npm i pug-element-loader

It's not packaged yet, so if you want to try it out, clone this repository and use it.

For use with webpack.

The following is an example of webpack.config.js.

module: {
    rules: [
        {
            test: /\.ce\.pug$/,
            use: ["pug-element-loader"],
        },
    ]
}

The ***.ce.pug file will then export a class object that inherits from HTMLElement, so all you have to do is define it as a custom element.

mixin sample-element(align)
    div.el-heading-lv2(style = `text-align: ${align};`)
        h2
            // block is the slot element.
            block
        p This is Sample.

All you have to do is register it as a custom element and write it in your HTML.

// The class name is exported with the mixin converted to Pascal case.
import SampleElement from './sample-element.ce.pug';

// ex. <sample-element align="center">Sample Text</sample-element>
customElements.define('sample-element', SampleElement);

Support list

I lack verification on everything, so if you find a bug, please report it to me and I will be very happy.

|Pug Docks|Support| |---|---| |Attributes|Support *1| |Case|Support| |Code|To be supported| |Comments|Support| |Conditionals|Support| |Doctype|Not Support| |Filters|Plans for support| |Includes|Pre Support *2| |Template Inheritance|Plans for support| |Interpolation|Pre Support *3| |Iteration|To be supported| |Mixins|Plans for support *4| |Plain Text|Support *5| |Tags|Support *6|

*1. Support for "Unescaped Attributes" and "Quoted Attributes" excluded.
*2 A simple pug file can probably be read, but is not fully validated.
*3 Only "String Interpolation, Escaped" is supported, but other features will be supported.
*4 Support will be promoted for use as multiple blocks, i.e. named slot elements.
*5 Support for "Literal HTML" excluded.
*6 "Self-Closing Tags", i.e. void elements, cannot be controlled by JavaScript, so it seems impossible to implement.

To do

  • From those that are "To be supported".
  • Verification of the functions you say you support ... What is support? 🤔