Code Monkey home page Code Monkey logo

mel's Introduction

MEL: Elisp HTML Templating

A honeycomb with the word 'mel' written in honey in the center.

Short and sweet HTML.

Usage

The mel function accepts any number of nodes and returns an HTML string. Each node is a list of the following form:

(TAG [attribute val...] CHILDREN...)

Tags

TAG must be a symbol staring with the name of an HTML tag.

Classes

The . separator can be used in a tag symbol name to indicate a class. It may be used multiple times. As a special case, if a tag symbol begins with a ., a div tag is implied.

IDs

A single # separator can be used to associate an ID with a tag. Note that the separator must be escaped with a \ in elisp. The @ separator is an alias for # which does not need to be escaped.

Attributes

An optional attribute vector may be added as the second element of a node list. Each attribute must be a symbol (optionally a keyword) followed by its value. The value will be coerced to its string representation.

Children

Any elements of a node specified after the tag and optional attribute vector are the node's children. They may be either strings or nodes.

Tempalte Files

An htmel file must contain an emacs-lisp program. When evaluated, the return value of the last expression must be a mel spec for a document. For example, the source for this page is stored in ./index.htmel. A mel file is similar to an htmel file, but the return value of each top-level sexp is collected into a list. This is useful for including partial templates within other templates (see below).

File Inclusion

Content stored in other files can be included via the mel-read function. The mel-read function can be used to parse and load files into a template.

mel's People

Contributors

progfolio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.