HTML Line Tree turns any text in Line Tree format into a pretty HTML document
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
MIT-LICENSE
README
README.md
gem-public_cert.pem
hlt.gemspec

README.md

What's new in the Hlt gem version 0.5.1

require 'hlt'

s =<<S
html {lang: 'en'}
  head
    title Testing 1 2 3
    meta {charset: 'utf-8'}
  body
    table {border: '1'}
      thead
        th Date
        th Type
        th Name
        th Credit
        th Debit
        th Balance
      - for item in bank['transactions'] do
        tr
          - for field in item
            td = field

S

hlt = Hlt.new(s)

h = {"bank"=>{"balance"=>" - ", "transactions"=>[["22 Oct 2014", "POS", "5487 22OCT45 , W P SMITHS PLC , EDINBURGH GB", " - ", "0.89", "£225.43"], ["25 Oct 2014", "D/D", "JAFFACAKESDIRECT", " - ", "12.00", "£213.43"], ["1 Nov 2014", "D/D", "EDINBURGH SPORTS", " - ", "8.00", "£205.43"], ["2 Nov 2014", "BAC", "PAYPAL", "12.80", " - ", " - "]]}}

puts hlt.render locals: h

Output:

<html lang='en'>
  <head>
    <title>Testing 1 2 3</title>
    <meta charset='utf-8'/>
  </head>
  <body>
    <table border='1'>
      <thead>
        <th>Date</th>
        <th>Type</th>
        <th>Name</th>
        <th>Credit</th>
        <th>Debit</th>
        <th>Balance</th>
      </thead>
      <tr>
        <td>22 Oct 2014</td>
        <td>POS</td>
        <td>5487 22OCT45 , W P SMITHS PLC , EDINBURGH GB</td>
        <td> - </td>
        <td>0.89</td>
        <td>£225.43</td>
      </tr>
      <tr>
        <td>25 Oct 2014</td>
        <td>D/D</td>
        <td>JAFFACAKESDIRECT</td>
        <td> - </td>
        <td>12.00</td>
        <td>£213.43</td>
      </tr>
      <tr>
        <td>1 Nov 2014</td>
        <td>D/D</td>
        <td>EDINBURGH SPORTS</td>
        <td> - </td>
        <td>8.00</td>
        <td>£205.43</td>
      </tr>
      <tr>
        <td>2 Nov 2014</td>
        <td>BAC</td>
        <td>PAYPAL</td>
        <td>12.80</td>
        <td> - </td>
        <td> - </td>
      </tr>
    </table>
  </body>
</html>

Introducing the HTML Line Tree (HLT) gem

The HTML Line Tree (HLT) gem generates HTML from text in Line-Tree format. e.g.

require 'hlt'

s =<<S
html {lang: 'en'}
  head
    title
    meta {charset: 'utf-8'}
    # link {rel: 'stylesheet', type: 'text/css', href: 'foo', media: 'screen'}
    # script {type: 'text/javascript', src: '123'}

  body
    script
[
// javascript goes here
]

S

Hlt.new(s).to_html

output:

puts Hlt.new(s).to_html


<?xml version='1.0' encoding='UTF-8'?>
<html lang='en'>
  <head>
    <title></title>
    <meta charset='utf-8'></meta>
  </head>
  <body>
    <script>
    // javascript goes here

</script>
  </body>
</html>

Resources