lotus/assets — pull request #2 by jodosha (2014-10-28 11:29:33+00:00)
Title: Assets helpers

## Helpers
Implement template helpers with `Lotus::Assets::Helpers`.

Given the following template:

```erb

Assets example

<%= stylesheet 'reset', 'grid', 'main' %>

<%= javascript 'https://code.jquery.com/jquery-2.1.1.min.js', 'application' %>
<%= javascript 'modals' %>

```

It will output this markup.

```html

Assets example

```

Let's have a look at the corresponding Ruby code.
In this example we use ERb, but remember that `Lotus::Assets` is compatible with
all the rendering engines such as HAML, Slim, Mustache, etc..

```ruby
require 'erb'
require 'lotus/assets'
require 'lotus/assets/helpers'

class View
include Lotus::Assets::Helpers

def initialize
@template = File.read('template.erb')
@engine = ERB.new(@template)
end

def render
@engine.result(binding)
end
end

View.new.render # => HTML markup
```

## Configurable assets

### Existing asset types

Right now the framework only supports javascripts and stylesheets.
If a developer wants to customize the output of those kind of assets he or she can do:

```ruby
require 'lotus/assets'

Lotus::Assets.configure do
define :javascript do
path '/js'
end
end
```

This will generate use `/js` as output path instead of `/assets`.
While stylesheets will still use the default value.

```html

```

### Custom asset types

The framework is so flexible that developers can define custom asset types.

```ruby
Lotus::Assets.configure do
define :custom do
tag %()
source %(%s.cst)
end
end
```

**Please note that this last feature is still in development, but here we have already a solid ground for it.**