Sha256: bd178a9d37c5ed089177ad4a55730386db0a1e95d0fa8b4034a74e8dc10fe236

Contents?: true

Size: 1.58 KB

Versions: 13

Compression:

Stored size: 1.58 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, [workflow, task, template_file].compact * "-", :cache_type => :async )
    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

13 entries across 13 versions & 1 rubygems

Version Path
rbbt-rest-1.8.21 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.20 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.19 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.18 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.17 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.16 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.15 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.14 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.13 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.12 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.11 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.10 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.9 lib/rbbt/rest/workflow/render.rb