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

fastapp

v0.1.2

Published

A html template engine design to create web apps.

Downloads

12

Readme

FastApp

A html template engine design to create web apps.

Npm version   Build Status   Coverage Status   Code Climate   Dependencies

Installation

npm install fastapp

Features

  • Complies with the Express web rooter.
  • Mark command tag using#{ code /}

Commands

The markup language is composed of tag of this form:

#{command first_Arg, second_Arg, ... /}

The available commands are:

  • set: Assign the value of the expression(2) to the variable name(1).
  • get: Replace this tag by the value of the expression(1).
  • get_if: If the condition(1) is true, replace this tag by the value of the expression(2) else by the second expression(3).
  • include: Insert the content of the file indicate by the value of the expression(1).
  • doLayout_: Insert the content of the child template.
  • extends_: Define the parent of this template (see extends).
#{set title,'MyPage' /}
#{set menu,'home' /}
#{extends '/model.html' /}
<div>...</div>
#{include '/menu-' + menu + '.html' /}
<p>Bienvenue sur #{get title/}</p>

Usage

You can use this script of three different ways. On command line: > node lib/fastapp.js [html_file]

On your script:

var fapp = require ('fastapp')
fapp.buildFile(path, null, function (err, data) {
 //...
});

Using Express:

var fapp = require('fastapp'),
    express = require('express'),
    app = express(),
    option = { /* ... */ }

// What's on /dist folder is freely accessible
app.get('/dist', express.static(__dirname + '/dist'));
// For the rest, we use the engine
app.get('/views', fapp.lookAt(__dirname + '/views', option));

app.listen(80);

Options

  • cache If true, will keep static page into memory.
  • params Array of values accessible via params.name
  • query Array of values accessible via params.query
  • debug Output debug information
  • open Open tag, defaulting to "#{
  • close Closing tag, defaulting to "/}"
  • directory Change of directory (default is ./views)

Extends

A real advantage about this template is to insert content of other pages. You have two way of doing this, the extends and include commands.

The extends allow to define a parent. This is always the last executed command on the page.

Example

./views/model.html
<html>
  <head>
    <title>#{get title/}</title>
    ...
  </head>
  <body>
    <header>
    ...
    #{include '/menu.html' /}
    </header>
    <div id="content">
    #{doLayout /}
    </div>
    <footer>...</footer>
  <body>
<html>
./views/index.html
#{set title 'MyPage' /}
#{set menu, 'home' /}
#{extends '/models.html' /}
<h1>Welcome #{get_if query.user!=null, query.user, 'new visitor'}!</h1>
<p>This is my page</p>
./views/menu.html
<ul class="nav">
  <li class="#{get_if menu=='home', 'active'/}"><a href="#">Home</a>
  <li class="#{get_if menu=='ptfl', 'active'/}"><a href="#">Portfolio</a>
  <li class="#{get_if menu=='about', 'active'/}"><a href="#">About</a>
</ul>
RENDER (indentation corrected) /index.html?user=Fab
<html>
  <head>
    <title>MyPage</title>
    ...
  </head>
  <body>
    <header>
    ...
      <ul class="nav">
        <li class="active"><a href="#">Home</a>
        <li class=""><a href="#">Portfolio</a>
        <li class=""><a href="#">About</a>
      </ul>
    </header>
    <div id="content">
      <h1>Welcome Fab!</h1>
      <p>This is my page</p>
    </div>
    <footer>...</footer>
  <body>
<html>

License

This code is under the BSD 3-Clause license.