Skip to content

Pure JavaScript HTML generator. You write JavaScript, we return HTML. No templates.

License

Notifications You must be signed in to change notification settings

mccomplete/curly-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CurlyHTML

Pure JavaScript HTML generator. You write JavaScript, we return HTML. No templates.

This:

div(
  label({"for": "rendering-method-dropdown"}, "How do you want to render your UI?"),
  select(
    {id: "rendering-method-dropdown"},
    option({value: "angular"}, "AngularJS"),
    option({value: "curly"}, "CurlyHTML"),
  )
)

Returns this:

<div>
  <label for="rendering-method-dropdown">"How do you want to render your UI?"</label>
  <select id="rendering-method-dropdown">
    <option value="angular">AngularJS</option>
    <option value="curly">CurlyHTML</option>
  </select>
</div>

How you'd call it in practice:

const div = useTag("div");
const label = useTag("label");
const select = useTag("select");
const option = useTag("option");

const container = document.getElementById("my-container-element");
container.innerHTML = div(
  label({"for": "rendering-method-dropdown"}, "How do you want to render your UI?"),
  select(
    {id: "rendering-method-dropdown"},
    option({value: "angular"}, "AngularJS"),
    option({value: "curly"}, "CurlyHTML"),
  )
);

As of this writing, the implementation is 23 lines of unobfuscated, uncompressed, readable JavaScript -- see for yourself. The implementation is less than half the length of the README.

You can do anything in CurlyHTML that you can do in JavaScript because it is JavaScript -- pure JavaScript.

It supports everything that HTML supports because HTML is just tags and attributes. And you tell CurlyHTML what tags you need.

(Why "CurlyHTML"? Because it's the opposite of AngularJS.)

About

Pure JavaScript HTML generator. You write JavaScript, we return HTML. No templates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published