Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

View helper for Rails #1

Closed
wants to merge 2 commits into from

1 participant

Wynn Netherland
Wynn Netherland

Simple helper to build correct markup, classes in Rails.

Wynn Netherland

Cleaning up some ghosts of projects past.

Wynn Netherland pengwynn closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2011
  1. Wynn Netherland

    adds view helper for rails

    pengwynn authored
  2. Wynn Netherland

    add span for button tag

    pengwynn authored
This page is out of date. Refresh to see the latest.
19 lib/zocial_helper.rb
View
@@ -0,0 +1,19 @@
+module ZocialHelper
+
+ def zocial_link_to(body, url, options={})
+ css_classes = options[:class].to_s.split(" ")
+ css_classes << 'zocial'
+ options[:class] = css_classes.uniq.join(" ")
+
+ link_to(content_tag(:span, body), url, options)
+ end
+
+ def zocial_button_tag(text, options={})
+ css_classes = options[:class].to_s.split(" ")
+ css_classes << 'zocial'
+ options[:class] = css_classes.uniq.join(" ")
+
+ button_tag(content_tag(:span, text), options)
+ end
+
+end
15 test/views/helpers.haml
View
@@ -0,0 +1,15 @@
+- @title = "View helpers for Zocial Buttons"
+
+%h1= @title
+
+
+
+%h2 Link helper
+
+= zocial_link_to "Sign in with Twitter", "#", :class => "twitter"
+%pre
+ %code
+ :plain
+ = zocial_link_to "Sign in with Twitter", "#", :class => "twitter"
+
+
19 test/views/view_helpers.rb
View
@@ -0,0 +1,19 @@
+module ViewHelpers
+
+ def zocial_link_to(body, url, options={})
+ css_classes = options[:class].to_s.split(" ")
+ css_classes << 'zocial'
+ options[:class] = css_classes.uniq.join(" ")
+
+ link_to(content_tag(:span, body), url, options)
+ end
+
+ def zocial_button_tag(text, options={})
+ css_classes = options[:class].to_s.split(" ")
+ css_classes << 'zocial'
+ options[:class] = css_classes.uniq.join(" ")
+
+ button_tag(text, options)
+ end
+
+end
Something went wrong with that request. Please try again.