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

lisp-markup

v0.4.0

Published

A lisp based template language for markup with a focus on macros.

Downloads

6

Readme

lisp-markup

Markup in lisp syntax with macros and templates.

Overview

lisp-markup is a lisp-like templating tool for javascript that outputs markup such as html.

The two most notable features of lisp-markup are its use of the lisp mentality of code as data, and a macro system that takes advantage of this to facilitate powerful and intuitive template macros written in javascript.

  • Lisp Mentality: Code as data.
    • Lisp2Markup allows you to use a javascript string in lisp syntax as your template, or build your template programmatically using javascript lists.
    • When javascript lists are used, templates may be written as JSON datastructures. Templates written this way still closely resemble lisp code.
  • Lisp-Like Macros:
    • Lisp, in my opinion, has the best macro system of any programming language. The fact that all code is data facilitates this.
    • Lisp2Markup takes advantage of this approach to macros, but without including the lisp programming language, only its syntax and "code as data" approach.
    • Macros are written in javascript and have access to the portion of the template they are applied on as a javascript datastructure.
    • Macros also have access to the data being used by the template for the conversion, and the original markup conversion function.

You can use the provided macro functions or write your own.

Built-In and Custom Markup Conversions

Lisp2Markup has built in markup conversion function for html and you may create your own conversion functions for other markup languages by providing a taghandler.

Built-In Markup Conversions Available

  • toHtml: convert to html.

Custom Markup Conversion

To make a custom markup conversion function, you must write a tag handler. The tag handler accepts the tagname and a set of properties, and returns a tuple containing the opening and closing tag strings.

function taghandler( tagname,properties){
    var open_tag_str = /* do stuff */;
    var close_tag_str = /* do stuff*/;

    return [open_tag_str, close_tag_str];
}

You can then generate your markup conversion from the taghandler:

var converter = customMarkupConverter(taghandler);

All markup conversion functions follow the following calling pattern.

markupConverter( l,data):
  • l: the template, whether a string in lisp syntax(TODO) or a javascript datastructure, to be converted to markup.
    • entries in l are handled accoring to the type of the entry:
      • lists within this list are evaluated recursively like in lisp.
      • objects are property sets which are added to current node in the markup. TODO allow using templates and macros to fill object properties.
      • a function in the first position of a list is a macro.
      • a function in a non-first position is a view function.
      • views in l are called with a data parameter which is the current context in the data.
        • view( data);
        • views must return a string.
      • macros in the template are called with the following parameters:
        • macro( template,data,markupConverter);
          • l: the current list this macro is applied to, which will include the macro itself in the first position.
          • data: for templating, this is the same parameter that is passed to markupCoverter( l,data), see more below.
          • markupConverter: macros are provided the current markupConverter function so they can do more magic.
          • The macro's return value is used in place of the original list with the macro.
          • If it returns a string, that string is inserted into the markup.
          • If it returns a list, the list is evaluated by the markupConverter
          • If it returns an object, the properties are added to the current node in the markup.
          • It may not return a function.
  • data:
    • this parameter allows your list datastructure to be used as a template.
    • the values in the final markup are filled in with the data values from this list.
    • Both tranformation and macro functions within l are passed this parameter as described above.