Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/calavera/hudson-erb-plugin

DSL to write Hudson's views with Ruby and ERB
https://github.com/calavera/hudson-erb-plugin

Last synced: about 2 months ago
JSON representation

DSL to write Hudson's views with Ruby and ERB

Awesome Lists containing this project

README

        

h2. Hudson ERB plugin

Actually this is a Maven plugin to use to develop Hudson's plugins and allows to write views with Ruby and ERB templates.

When we build a Hudson's plugin with Maven it generates the jelly files that Hudson needs from our ERB templates.

_WARNING_: Right now it just includes a subset of the form views.

h3. Configuration

Add this to the pom file:



...

org.mirah.hudson
hudson-erb-plugin


erb-compile



h3. Usage

Add your ERB templates in the same place that you added your jelly files
with the same name but with extension @jelly.erb@, for instance if we have a
configuration form in @src/main/resources/hudson/plugin/foo/config.jelly@ we
have to replace it with
@src/main/resources/hudson/plugin/foo/config.jelly.erb@.

h3. Example

We can replace this code:





with this one:


<% view do %>
<% entry 'Verbose', :description => 'Show Mirah AST generation' do %>
<%= checkbox 'verbose' %>
<% end %>

<% entry 'Script', :description => 'Mirah script' do %>
<%= textarea 'command' %>
<% end %>
<% end %>

We can see this same example working in the "Mirah Interpreter plugin":https://github.com/calavera/mirah.hpi/blob/master/src/main/resources/hudson/plugins/mirah/MirahInterpreter/config.jelly.erb

h3. Extensions

In some cases perhaps we want to extend the dsl with our custom tags. We just need to create a file called @ext.rb@ under the directory
@src/main/resources/hudson_erb@ into our plugin and add the custom code to the module @Hudson::View@:


module Hudson
module View
def foo
''
end
end
end

Then we can use that method in our views as we used any other:


<% entry 'Foo', :description => 'My foo input' do %>
<%= foo %>
<% end %>