Sha256: 2152772a31ef8b857a41fee07266da42c8f9a22bd5af99c1c9518d71ad2d898d

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

require 'rbbt/util/open'

require 'haml'
module WorkflowRESTHelpers

  def workflow_render(template, workflow = nil, task = nil, params = {})
    workflow = consume_parameter(:workflow, params) if workflow.nil?
    task     = consume_parameter(:task, params) if workflow.nil?
    job      = consume_parameter(:job, params) if job.nil?

    template_file = locate_workflow_template(template, workflow, task)

    locals = params.dup
    locals[:workflow] = workflow if workflow
    locals[:task]     = task if task

    if layout
      layout_file = workflow.libdir.www.views[workflow.to_s]["layout.haml"] if workflow.libdir
      layout_file = locate_template("layout") unless layout_file and layout_file.exists?
    else
      layout_file = nil
    end

    if job 
      locals[:job]      = job 
      @step = job
      cache_type = execution_type(workflow, task)
      cache_file = job.file('html')
      render(template_file, locals, layout_file, [task,workflow,job.name] * "-", :cache_type => cache_type, :cache_file => cache_file)
    else
      render(template_file, locals, layout_file)
    end
  end

  def workflow_partial(template, workflow = nil, task = nil, params = {})
    workflow = consume_parameter(:workflow, params) if workflow.nil?
    task     = consume_parameter(:task, params) if workflow.nil?

    template_file = locate_workflow_template(template, workflow, task)

    locals = params.dup
    locals[:workflow] = workflow if workflow
    locals[:task]     = task if task

    render_partial(template_file, locals)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rbbt-rest-1.4.12 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.4.11 lib/rbbt/rest/workflow/render.rb