monit - How to erb'up a monitrc configuration file

Below is my delayed_job monitrc file, i wanted to use it as an erb template so that i can dynamically set the RAILS_ENV variable. Does anyone know how to do it?set daemon 120check process delayed_job with pidfile /home/rails/public_html/myapp/shared/pids/delayed_job.pid start program = "/usr/bin/env RAILS_ENV=production /home/rails/public_html/myapp/current/script/delayed_job start" stop program = "/usr/bin/env RAILS_ENV=production /home/rails/public_html/myapp/current/script/delayed_job stop"...Read more

erb - Custom helper with block

I'm using the current release 4.3.3 of Middleman.I'd like to define a custom helper which accepts a block. For the sake of simplicity, here's a nonsensical example of wrap_me which wraps the block content with the given tag. It should be possible to implement this with capture_html provided by Padrino (which is explicitly mentioned in the Middleman docs):module CustomHelpers def wrap_me(tag, &block) captured = capture_html(&block) concat_content "<#{tag}>" + captured + "</#{tag}>" endendPut to use in ERB:<%= wrap_...Read more

erb - Client-Side Rendering: How to leverage server/client side templates?

I'm currently implementing a ruby/sinatra application using erb as the rendering engine using client-side rendering using handlebars/mustache templates as well. I'm implementing a certain list view in which the list elements will be rendered using the client side solution when javascript is present and fallback to server side when not (targeting crawlers this way). But I'm left with the folliowing issue: I basically have two templates written in two different markups which produce the same html. I'd love to "write once, run everywhere". How are...Read more

erb - Check if a variable is undef in puppet template

What is the proper way to check if a variable is undef in a puppet template?In the manifest the variable is defined as follows$myvar = undefHow is this checked in the template?Is saw the following two variants<% if @myvar -%><% end -%>and<% if not @myvar.nil? and @myvar -%><% end -%>They both seem to work in my case, but I wonder if the first approach fails in on certain cases?...Read more

erb - How to access the article layout data property in middleman 4?

I am trying to migrate my blog from Middleman 4. In my index.html.erb file I have code like this:<% page_articles.each_with_index do |article, i| %> <% if article.data.layout == 'post' %> <%= partial "post", :locals => { :article => article} %> <% elsif article.data.layout == 'micro' %> <%= partial "micro", :locals => { :article => article} %> <% end %><% end %>This worked fine in Middleman 3 and I could use a different partial depending on the layout property defined ...Read more

erb - Chef Template Nested Loops

I have a small problem with my chef cookbook, i'm trying todo a nested loop (loop in loop). I have a array with multiple levels and i would like to loop all levels in a chef template. Right now i'm down at the following: Template: <% @countries.each do |country| %> <% @countries[@country].each do |key, val| %> <Publication <%= @country @key @val %> /> <% end %> <% end %>Attribute:default['countries']['IE'] = {'57'=>'val2','58'=>'val2','6...Read more

puppet - ERB template not picking up variables from hieradata

I have a puppet infrastructure and I've created a new module which refers to variables that exist in the hieradata yaml files, that all works fine in the manifest section. However, when I'm referring to them in an erb template the variables display nothing after the puppetrun. The file is there, just not the variables..init.ppclass cms_nxlog ($msi_file) { anchor { 'cms_nxlog::begin': }->file { "C:/CMS/${cms_nxlog::msi_file}": ensure => 'file', source => "puppet:///modules/cms_nxlog/${cms_nxlog::msi_file}", owner...Read more

erb - slim multiple lines of logic setup

In ERB I can do this to setup variables:<% skills_list = [ { var_name: @expert_skills, label: "Expert Skills" { var_name: @advanced_skills, label: "Advanced Skills" { var_name: @familiar_skills, label: "Familiar Skills" ]%>How do I accomplish the same thing in slim without putting - at the beginning of each line?...Read more

How to get an array index in erb template in puppet

I need to be able to generate following content of the file (for zookeeper installation):server.1=$zk.server1.full.hostname:2888:3888server.2=$zk.server2.full.hostname:2888:3888server.3=$zk.server3.full.hostname:2888:3888when I have an array of server hostnames (example shows # of servers = 3). I tried something like following:<% @regionserver_list.each do |this_server| -%>server. =<%= this_server %>:2888:3888<% end -%>That seems not correct as and I am struggling with getting an array index (need to start from 1). The point ...Read more

How to change key binding for ERB tag in TextMate 2?

When I want to insert an ERB tag inside an .html.erb file in TextMate 2, the default key binding is ctrl+>. Pressing it several times cycles between <%= %>, <% %>, etc. I would like to change it to cmd+shift+.. How can I achieve this? I have tried finding the key binding for ERB tags in "edit bundles..." but couldn't locate it.Thanks for your help!...Read more

erb - Arithmetic operations inside templates

I'm trying to add a number to a parameter inside a puppet template as below"https://localhost:<%= 9443 + @offset %>/service/" This gives me the following error.Detail: String can't be coerced into Fixnum'offset' is a numeric value. Is it possible to do this kind of arithmetic operations in puppet?...Read more

erb - How to include a subtemplate in a Puppet template

I'm trying to include a subtemplate in a template for one of my Puppet modules. Here's how I do the include in my base template:<% def import(fname) erb = File.open(File.dirname(__FILE__) + "/" + fname) { |fp| ERB.new(fp.read) } erb.run end%><%= import("subtemplate.erb") %>This works fine if I render it with erb command-line tool. However, during the Puppet run the import is silently ignored, i.e. the base template is rendered with a blank line where the rendered subtemplate should be. There are no errors generated.What...Read more

erb - ruby and nested loops

Hi I'd like some help on how to code this in erb in puppet, basically I haveserver::actionhost { 'details': servername[ 'felix', 'washington', ], ipa [ '192.168.43.5', '192.168.43.11', ], enviro [ 'prod', 'uat', ],}I now want to print this out to a file with each respective element from each array in one line, i.e the output from the template file in my class should be like:felix 192.168.43.5 prodwashington 192.168.43.11 uatWhen I attempted this I wrote the following code in my template file:<% servername.each do |name| -%><% ...Read more

puppet - Ruby erb template 'or' operator

I have a puppet manifest which uses an erb template.This is the correct syntax according to the documentation, and it works perfectly. <% if foo != bar %> derp<% else %> herp<% end %> How can I combine the if statement with an 'or' operator? Here are the following syntaxes that I have tried, however they return an error: <% if foo != bar or if slurp != burp %> derp<% else %> herp<% end %> Error: Could not run: /etc/puppet/modules/gitlab/templates/gitlab.yml.6-7-stable.erb:275: syntax error, unexpected...Read more

erb - Rails5 + Paperclip: Image_tag for a collection of images displays whole image array

Models:Place has_many PhotosPhoto belongs_to PlaceI wan to find and display all photos that belong to a place.Controller:@place = Place.find(params[:id])view:<% if @place.photos.exists %> <%= @place.photos.each do |place| %> <%= image_tag place.photo.url(:medium)%> <% end %><% end %>Id displays requested photos - but also whole photo array:[#<Photo id: 1, place_id: 6, title: nil, status: nil, description: nil, photo_file_name: "IMG_0436.JPG", photo_content_type: "image/jpeg", photo_file_size: 475199...Read more