Project

hlt

0.0
Low commit activity in last 3 years
No release in over a year
Intended for building HTML from a kind of Slim template.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.5, >= 1.5.0
 Project Readme

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