Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yorickpeterse/inko-builder
An Inko library for generating XML and HTML
https://github.com/yorickpeterse/inko-builder
html inko xml
Last synced: 18 days ago
JSON representation
An Inko library for generating XML and HTML
- Host: GitHub
- URL: https://github.com/yorickpeterse/inko-builder
- Owner: yorickpeterse
- License: mpl-2.0
- Created: 2023-07-21T02:53:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-19T22:40:02.000Z (6 months ago)
- Last Synced: 2024-11-28T11:05:30.095Z (3 months ago)
- Topics: html, inko, xml
- Language: Makefile
- Homepage: https://yorickpeterse.github.io/inko-builder/
- Size: 56.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Builder
Builder allows generating of XML and HTML using an Inko DSL, without the need
for a template engine of sorts. It's inspired by the [Ruby "Builder"
project](https://github.com/tenderlove/builder), which does the same but in
Ruby.# Requirements
- Inko 0.15.0 or newer
# Installation
```bash
inko pkg add github.com/yorickpeterse/inko-builder 0.13.0
inko pkg sync
```# Examples
Generating a simple XML document:
```inko
import builder.xml (Document)
import std.stdio (STDOUT)class async Main {
fn async main {
let out = STDOUT.new
let doc = Document.with(fn (doc) {
doc.element('person').with(fn (person) {
person.element('name').text('Alice')
person.element('city').text('Foo Town')
})
})out.print(doc.to_pretty_string)
}
}
```This produces the following XML:
```xml
Alice
Foo Town```
Generating a simple HTML document:
```inko
import builder.html (Document)
import std.stdio (STDOUT)class async Main {
fn async main {
let out = STDOUT.new
let doc = Document.html('en', fn (html) {
html.head.with(fn (head) { head.title.text('My website') })html.body.with(fn (body) { body.p.text('Hello!') })
})out.print(doc.to_pretty_string)
}
}
```This produces the following HTML:
```html
My website
Hello!
```
For more information, refer to the [API
documentation](https://yorickpeterse.github.io/inko-builder/).# License
All source code in this repository is licensed under the Mozilla Public License
version 2.0, unless stated otherwise. A copy of this license can be found in the
file "LICENSE".