Hi, how do partial are rendered in Middleman?
I need to render a partial in a thor template.
Regards
Lorenzo
Hi, how do partial are rendered in Middleman?
I need to render a partial in a thor template.
Regards
Lorenzo
Hi, just some more information about my question. I’m creating a task in order to sync middleman with https://prismic.io/ (a content repository)
I’m using a template in order to build middleman pages in a thor task.
This is an abstract of my template page:
<div id="formContatti" class="row">
<div>
<h2 class="subheader" id="chiSiamo"><%= @siteData ['KeyValuePairs']['box-form-title']['value'].as_text %></h2>
</div>
<div class="wufooNew columns">
<%= partial("wufooForm", :locals => { :sitedata => @siteData}) %>
</div>
<div class="large-6 medium-6 columns">
<ul class="large-block-grid-1">
<% @pageData ['blocks']['rassicurazioni']['blocks'].each do |i, block| %>
<li>
<h4 class="subheader"><%= block ['icona']%> <%= block ['title']%></h4>
<span class="medium"> <%= block ['body']%> </span>
</li>
<% end %>
</ul>
</div>
</div>
As you can see I would like to use a “partial” function from padrino helpers.
Here is the code of my task:
require 'middleman-core/cli'
require 'middleman-core/extensions'
require 'date'
require 'middleman-blog/uri_templates'
require 'padrino-helpers'
require 'padrino/rendering'
# CLI Module
module Middleman::Cli
# A thor task for creating new projects
class SyncPages < Thor
include Thor::Actions
include ::Middleman::Blog::UriTemplates
include Padrino::Helpers
check_unknown_options!
namespace :syncPages
def self.source_root
ENV['MM_ROOT']
end
desc 'syncPages NAME [options]', 'Create new project NAME'
method_option 'document_type',
aliases: '-T',
default: 'default',
desc: "Il document type"
# The syncPages task
# @param [String] tag
def syncPages(tag='pages-group')
prismic_middleman = shared_instance.prismic_middleman
shared_instance.logger.info " Contentful Sync: Start..."
site = prismic_middleman.get_by_tags ('site')
siteData = prismic_middleman.getBlockData (site.first)
prismic_middleman.get_by_tags(tag).each do |document|
pageData = prismic_middleman.getBlockData (document)
@title = pageData ['title']
@slug = pageData ['slug']
@category = document["block.category"].slug
@pageData = pageData
@siteData = siteData
prismic_inst = shared_instance.prismic_middleman(options[:prismic])
path_template = uri_template prismic_inst.options.permalink
params = {category: @category, title: @slug}
article_path = apply_uri_template path_template, params
pageTemplate = 'fdt_templates/' + pageData ['pageType'].downcase + '.erb'
template pageTemplate, File.join(shared_instance.source_dir, article_path + prismic_inst.options.default_extension)
#print template pageTemplate
end
end
private
def shared_instance
@shared_instance ||= ::Middleman::Application.server.inst
end
end
def self.exit_on_failure?
true
end
end
Running this task I’ve got this error:
.rvm/gems/ruby-2.1.1/gems/padrino-helpers-0.12.2/lib/padrino-helpers/output_helpers.rb:33:in `render': super: no superclass method `render' for #<Middleman::Cli::SyncPages:0x000001054a2ff8> (NoMethodError)
What do I have to do in order to render a partial in this task? I’m able to render all other padrino helpers like tag, link ecc. but not the partial helper. I do not understand how the render of the partial should be done.
Can someone please give me some indication?
Regards
Lorenzo