Sin descripción

Matheus Giovani ec3855642f added build configuration hace 3 años
examples 2fd15c8dc1 added support for comments to virtual-dom hace 3 años
packages ec3855642f added build configuration hace 3 años
test ec3855642f added build configuration hace 3 años
.gitignore b508f2f301 fixes gitignore hace 3 años
.gitmodules bfa4cc8e1f added virtual-dom submodule hace 3 años
.npmignore 43d0b5515e fixes reactivity hace 3 años
LICENSE d873f3a526 first commit hace 3 años
README.md e5f79a8374 added implementation tag and one new example hace 3 años
jest.config.js 57dbd2e0b8 general refactor hace 3 años
nodemon.json 5daa55e05f fixed text and HTML related things hace 3 años
package.json ec3855642f added build configuration hace 3 años
tsconfig.json dd48e19f34 reformulated component declaration hace 3 años
webpack.config.js 2fd15c8dc1 added support for comments to virtual-dom hace 3 años

README.md

pupper.js icon

pupper.js

pupper.js is a reactive template engine based in pugjs.

This is a BETA project, it can change drastically over time, so use it with caution for now and stay updated! :D


Basic syntax

pupper.js is based in pugjs, you can learn about pugjs's syntax here.

There's some new syntax added to use the reactivity:

  • {{ variable }} Renders the contents of variable as text, replacing HTML entities with escaped entities.
  • {- variable -} Renders the literal content of variable as-is

How to use

You can integrate pupper.js to your application by using one of the given loaders that compiles .pupper files into Javascript:


Or, you can integrate using the API:

const pupper = require("@pupperjs/core");
const Renderer = pupper.Renderer;

// Compiles the template to a string
const template = pupper.compileToStringSync(/*pupper*/`
template
    .test
        span.hello-world(id={{ id }})
            ={- content -}
`);

// Create a renderer (view) with some starting data
const renderer = new Renderer(template, {
    id: "the-id",
    content: "Hello, beautiful world!"
});

/**
 * <div class="test">
 *      <span class="hello-world" id="the-id">
 *          Hello, beautiful world!
 *      </span>
 * </div> 
 */
renderer.renderToString();