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

minko

v0.0.0-dev.4

Published

A simple but powerful backend rendering framework.

Downloads

4

Readme

Minko

A simple but powerful backend rendering framework.

Inspired by the components concept behind other frameworks like React, Angular or Vue, Minko will try its best to provide an easy but powerful toolset to split your website views into easier to manage components.

How to use

Minko was made to be very easy to setup and work without any extra build step. Use it is simple as doing npm install minko and requiring it.

var Minko = require('minko').Minko;  // We require the class

var minko = new Minko();  // We create a new Minko instance

minko.addComponentFromFile("my-component", /* A Minko monofile path */);  // We load a component from a monofile

const htmlCode = await minko.renderToString("my-component");  // We render my-component and get an async html code (1)

1: To use await, you will need to be inside an async method. If it isn't the case, consider using Promise "then" and "catch" methods

See examples folder to see how powerful Minko is.

How it works

In Minko, components are split into 3 parts, the scripts (JS), the markup (HTML) and the styles (CSS).

The scripts part is plain old JavaScript able to manage the other two parts.

Scripts are split into kinds, but currently the only script kind available is the prerender kind. In monofiles, the kinds are represented by the presence of properties, like this: <script prerender>...</script>.

Those script have a special this variable containing its current Minko DOM representation (see src/dom/ComponentElement.ts). It has access to component properties with this.props and component children array with this.children, it can also be used to change the way markup and styles are generated.

The markup and styles part are handled with Handlebars using the variables provided by the prerender script. The variables can be set with this.setVariables({ ... }) method.

Only markup is required to make a working component.

Components ? Monofiles !

Minko is able without any other tool to load components in files called monofiles, made in a language called MinkoHTML. This language was made to look like plain HTML, but it isn't, so don't confuse yourself.

<script prerender>
    ...
</script>

<template>
    ...
</template>

<style>
    ...
</style>

MinkoHTML only supports some tags like <script>, <template> and <style>.

These tags are handled in special way. <script> is executed, <template> and <style> are preprocessed and rendered.

To add a component from monofiles, you can use/

    minko.addComponentFromFile("my-component", __dirname + "/components/my-component.mko");

Don't want monofiles ?

You really don't want to use monofiles ? No problem. Minko supports that.

minko.addComponent('my-component', {
    scripts: {
        prerender: function () {
            this.setVariables({
                myVar: "Hello World!"
            });
            ...
        },
    },

    markup: `
        <h1>{{ myVar }}</h1>
    `,

    style: `
        h1 {
            text-align: center;
        }
    `,
});