0.0
No commit activity in last 3 years
No release in over 3 years
HMote plugin for Cuba
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 3.4.0
= 1.2.2
= 0.6.3

Runtime

~> 1.3
 Project Readme

hmote-render

HMote plugin for Cuba.

Usage

To use HMote in Cuba, you need to load the HMote::Render plugin as shown below:

require "hmote"
require "hmote/render"

Cuba.plugin(HMote::Render)

HMote::Render provides three helper methods for rendering templates: partial, view and render.

Cuba.define do
  on "about" do
    # `partial` renders a template without a layout.
    res.write partial("about")
  end

  on "home" do
    # `view` renders a template within a layout.
    res.write view("about")
  end

  on "contact" do
    # `render` is a shortcut to `res.write view(...)`
    render("contact")
  end
end

By default, HMote::Render assumes that all view templates are placed in a folder named views and that they use the .mote extension. Also for view and render methods, it assumes that the layout template is called layout.mote.

The defaults can be changed through the layout and view_path class methods:

class App < Cuba
  layout("admin")
  view_path("views/admin")
end

Layouts

To render inner content into a layout, use the {{! content }} tag.

<html>
  <head>
    <title>Mote Layout</title>
  </head>
  <body>
    <h1>Hello, world!</h1>

    {{! content }}
  </body>
</html>

Helpers

You can use the app variable to access the application helpers.

Cuba.define do
  def h(unsafe)
    ...
  end
end
<h1>{{! app.h("unsafe") }}</h1>

{{ app.partial("list") }}

Contributing

  • Fork the project.
  • Use make install to install dependencies.
  • Use make test to run the test suite.
  • Create a pull request with your changes.

Installation

$ gem install hmote-render