Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/soveran/hypertext

Hypertext authoring with Ruby
https://github.com/soveran/hypertext

Last synced: 3 months ago
JSON representation

Hypertext authoring with Ruby

Awesome Lists containing this project

README

        

Hypertext
=========

Hypertext authoring

Description
-----------

Hypertext allows you to write HTML from Ruby.

Usage
-----

A basic example would look like this:

```ruby
html = Hypertext.new do |h|
h.tag :div, "data-index-number" => 123, class: "greeting" do
h.tag :h1 do
h.text "hello world"
end

h.tag :hr

h.tag :p do
h.text "nice to meet you"
end
end
end

puts html.to_s

#


#


# hello world
#


#

#


# nice to meet you
#


#

```

DSL
---

As an experimental feature, Hypertext provides a DSL for
describing an HTML document in a way that resembles
[Markaby](https://github.com/markaby/markaby).

```ruby
require "hypertext"
require "hypertext/dsl"

person_name = "Foo Bar"

html = Hypertext::DSL.new do
form action: "/", method: "post" do
input name: "person[name]", value: person_name
input type: "submit"
end
end

puts html.to_s

#
#
#
#
```

Installation
------------

```
$ gem install hypertext
```