An open API service indexing awesome lists of open source software.

https://github.com/skirmish/html

html generation
https://github.com/skirmish/html

golang-library html-generation html5

Last synced: 5 months ago
JSON representation

html generation

Awesome Lists containing this project

README

          

# Html

A highly opinionated code driven HTML generator.

Usage:
```golang
page := []HtmlElement{
DocType(),
Html(Lang("en")).AddElements(
Head().AddElements(
Meta(Key("charset", "utf-8")),
Title().AddElements(Content("Page Title")),
Style().AddElements(Content(
"ul.samples {list-style: none; margin: 0; padding: 0;" +
" margin-block-start: 1px; margin-block-end: 1px;}\n" +
"ul.samples li {display: inline-block; width: 300px;}\n" +
"ul.samples li.good {background-color: #008000;}\n")),
),
Body().AddElements(
Heading(Level(1)).AddElements(Content("The Title of the Page")),
P().AddElements(Content("This is the first sentence."))),
Ul().AddElements(
Li().AddElements(
Img(Src("data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBIAAAA7UlEQVR4"+
"nGJiwAMGXJJZUFCwrmO95LL/3+tBfBaYhByblY1AMIj1ZHLg54sHQSxGqJzBPn4o61/SV4Zn728imyh4+"+
"y8IHNv2/SMWywPmZP/9e5abQXsWNqfxMcz6G4XLtZ8YPjKkMOL0Fve+v244JRmUPz5ckINTNvDD37/lErhkdX"+
"f9/TtNGpesQOyfv7txW/zz708HKJMFVUYvxJSF4dpBbJrUpzz9+/fvr21YpCSK7oKC96QfppS401VwyAdiBpL"+
"ganCsHA7gwJAyX/MIJPWllRtVHOzawEAGhuub//Z8wO1BTEB+0gQEAAD//3QpXYUSeN4MAAAAAElFTkSuQmCC")),
),
),
),
}

output := ""
for _, el := range page {
output += el.Render()
}
```

HTML5 elements are currently supported although they are mostly
only at the bare minumum.

Notes:
This is not optimized yet, first we'll work on correctness, then once it's fairly stable then working on making it
faster will happen.

All valid html5 tags *want* to be implemented, but for now it's driven by the ones currently in use.

TODO:
* Add Validation
* Add Variables & Conditionals
* Optimize
* Test
* Add CSS

HTML Tags
```









-



    1. <section>
      <select>
      <small>
      <source>
      <span>
      <strong>
      <style>
      <sub>
      <summary>
      <sup>
      <svg>
      <table>
      <tbody>
      <td>
      <template>
      <textarea>
      <tfoot>
      <th>
      <thead>
      <time>
      <title>
      <tr>
      <track>
      <u>
      <ul>
      <var>
      <video>
      <wbr>
      ```