Last active
December 13, 2015 23:19
-
-
Save micahgodbolt/4991146 to your computer and use it in GitHub Desktop.
Partial specific variables using get-serve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Block syntax | |
<% | |
if !defined? title | |
title = "Default Title" | |
end | |
%> | |
<h2><%= title %></h2> | |
<p>Blah blah blah blah</p> | |
# Calling your partials | |
<%= render "/partials/block", :locals => { :title => "Past Events" } %> | |
<%= render "/partials/block", :locals => { :title => "Upcoming Events" } %> |
Just noticed I was missing the closing brace on the second example. That could cause things to blow up. Fixed.
oh !!! hahah :) sorry! I accidently was calling it a previous time without the variable being stated.
Yup, that does the trick! thanks.
Oh last thing. I think it's render, not partial. Otherwise you can do <%= render :partial => "file/name" %>
Huh. I haven't used Serve, but I have used Sinatra on a lot of projects. I use sinatra-partial which gives me a partial
method, which is what my example was based on.
Glad I could help. Ruby is awesome. It's a breath of fresh air after 10 years of PHP.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's correct. I've got it rendering just fine if I remove the <%= title %> but i get an error if I put it back in.
Just to make sure you know, this is in the context of using Serve (get-serve.com) not a rails project or anything.