Skip to content

Instantly share code, notes, and snippets.

View pacifists's full-sized avatar

Rytis Lukosevicius pacifists

View GitHub Profile
module Liquid::Tags
class PageBanners < ::Liquid::Tag
Syntax = /(#{::Liquid::Expression}+)\s+max\s+([0-9]+)/
def initialize(tag_name, markup, tokens, context)
if markup =~ Syntax
@collection_name = $1
@max_number = $2
@pacifists
pacifists / loco_tip_1.html
Created October 7, 2011 06:27 — forked from did/loco_tip_1.html
How to post a comment related to an artist
<h2>{{ artist.name }}</h2>
<div>{{ artist.bio }}</div>
{% with_scope artist: artist._id %}
{% assign comments = contents.comments %}
{% if comments == empty %}
require 'active_support/dependencies'
module ActiveSupport::Dependencies
alias_method :require_or_load_without_multiple, :require_or_load
def require_or_load(file_name, const_path = nil)
if file_name.starts_with?(Rails.root.to_s + '/app')
relative_name = file_name.gsub(/^#{Rails.root.to_s}/, '')
@engine_paths ||= Rails::Application.railties.engines.collect{|engine| engine.config.root.to_s }
@engine_paths.each do |path|
engine_file = File.join(path, relative_name)
module MyApp
class IncViewsCounterFor < ::Liquid::Tag
Syntax = /(#{::Liquid::Expression}+)?/
def initialize(tag_name, markup, tokens, context)
if markup =~ Syntax
@name = $1
else
raise ::Liquid::SyntaxError.new("Syntax Error in 'inc_views_counter_for' - Valid syntax: inc_views_counter_for <content>")