Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:tablatom/hobo
Browse files Browse the repository at this point in the history
  • Loading branch information
tslocke committed Jun 27, 2008
2 parents 42784f4 + 5265853 commit 9f22821
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 29 deletions.
7 changes: 7 additions & 0 deletions hobo/lib/action_view_extensions/helpers/tag_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module ActionView::Helpers::TagHelper
alias_method :tag_without_doctype, :tag
def tag(name, options = nil, open = false, escape = true)
open = !scope.xmldoctype
tag_without_doctype(name, options, open, escape)
end
end
1 change: 1 addition & 0 deletions hobo/lib/hobo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ def enable
require 'active_record/has_many_through_association'
require 'active_record/association_proxy'
require 'active_record/association_reflection'
require 'action_view_extensions/helpers/tag_helper'

ActionView::Template.register_template_handler("dryml", Hobo::Dryml::TemplateHandler)

Expand Down
8 changes: 4 additions & 4 deletions hobo/lib/hobo/dryml/template_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def render_tag(tag_name, attributes)
end


def element(name, attributes, content=nil, escape = true, &block)
def element(name, attributes, content=nil, escape = true, empty = false, &block)
unless attributes.blank?
attrs = []
if escape
Expand All @@ -488,10 +488,10 @@ def element(name, attributes, content=nil, escape = true, &block)
end

content = new_context(&block) if block_given?
res = if content
"<#{name}#{attr_string}>#{content}</#{name}>"
res = if empty
"<#{name}#{attr_string}#{scope.xmldoctype ? ' /' : ''}>"
else
"<#{name}#{attr_string} />"
"<#{name}#{attr_string}>#{content}</#{name}>"
end
if block && eval("defined? _erbout", block.binding) # in erb context
_output(res)
Expand Down
11 changes: 0 additions & 11 deletions hobo/lib/hobo/static_tags
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ abbr
acronym
address
applet
area
b
base
basefont
bdo
big
blockquote
body
br
button
caption
center
cite
code
col
colgroup
dd
del
Expand All @@ -29,7 +25,6 @@ em
embed
fieldset
font
frame
frameset
h1
h2
Expand All @@ -38,29 +33,23 @@ h4
h5
h6
head
hr
html
i
iframe
img
ins
isindex
kbd
label
legend
li
link
map
menu
meta
noframes
noscript
object
ol
optgroup
option
p
param
pre
q
s
Expand Down
14 changes: 7 additions & 7 deletions hobo/taglibs/rapid_forms.dryml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
auth_token = if method.nil? || method == 'get' || request_forgery_protection_token.nil?
''
else
element(:input, :type => "hidden",
element(:input, {:type => "hidden",
:name => request_forgery_protection_token.to_s,
:value => form_authenticity_token)
:value => form_authenticity_token}, nil, true, true)
end

page_path = if request.post? || request.put? && params[:page_path]
Expand Down Expand Up @@ -100,7 +100,7 @@

<def tag="input"><%=
if attributes[:type]
element :input, attributes
element :input, attributes, nil, true, true
elsif !can_edit?
view
else
Expand Down Expand Up @@ -189,7 +189,7 @@
ajax_attributes[:message] ||= label
func = ajax_updater(url, update, ajax_attributes)
html_attributes.update(:onclick => "var e = this; " + func, :type =>'button', :value => label)
element(:input, html_attributes)
element(:input, html_attributes, nil, true, true)
else
button_to(label, url, html_attributes)
end
Expand All @@ -205,7 +205,7 @@
func = ajax_updater(object_url(this), update, ajax_attributes)
html_attributes.reverse_merge!(:type =>'button', :onclick => func, :value => label)

element :input, add_classes(html_attributes, "button update-button update-#{this.class.name.underscore}-button") %>
element :input, add_classes(html_attributes, "button update-button update-#{this.class.name.underscore}-button"), nil, true, true %>
</def>


Expand Down Expand Up @@ -234,7 +234,7 @@
scope.collection_contains_delete_button = true if fade
attributes[:value] = label
attributes[:onclick] = "Hobo.removeButton(this, '#{url}', #{js_updates(update)}, {fade:#{fade}, confirm: #{confirm.inspect}})"
element(:input, attributes)
element(:input, attributes, nil, true, true)
end
end
else
Expand Down Expand Up @@ -264,7 +264,7 @@
ajax_attributes[:params] = { class_name => fields } unless fields.empty?
func = ajax_updater(object_url(new.class), update, ajax_attributes)
element :input, add_classes(attributes.merge(:type =>'button', :onclick => func, :value => label),
"button create-button create-#{class_name}-button")
"button create-button create-#{class_name}-button"), nil, true, true
end
%></def>

Expand Down
35 changes: 29 additions & 6 deletions hobo/taglibs/rapid_pages.dryml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<def tag="base-page" attrs="title, full-title, doctype, nicedit">
<def tag="base-page" attrs="title, full-title, nicedit">
<% full_title ||= "#{title} : #{app_name}" %>
<doctype param version="&doctype || 'HTML 4.01 STRICT'"/>
<html>
<html merge-attrs>
<head param>
<title param><%= full_title.gsub(/<.*?>/, '') %></title>
<do param="stylesheets">
Expand All @@ -12,7 +11,7 @@

<do param="scripts">
<javascript param name="#{'nicedit, ' if nicedit} prototype, effects, dragdrop, controls, lowpro, hobo-rapid, application"/>
<do param="fix-ie6"><%= "<!--[if lt IE 7]>" %><javascript name="IE7"/><%= "<![endif]-->" %></do>
<if-ie version="lt IE 7" param="fix-ie6"><javascript name="IE7"/></if-ie>
<hobo-rapid-javascripts param/>
</do>
</head>
Expand All @@ -21,7 +20,6 @@
</html>
</def>


<def tag="simple-layout">
<base-page merge>
<body: param>
Expand Down Expand Up @@ -290,7 +288,7 @@
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ' +
'"http://www.w3.org/TR/html4/loose.dtd">'
when "XHTML 1.0 STRICT"
'!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ' +
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ' +
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
when "XHTML 1.0 TRANSITIONAL"
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' +
Expand All @@ -301,6 +299,31 @@
end
%></def>

<def tag="html" attrs="doctype">
<% doctype ||= 'XHTML 1.0 TRANSITIONAL' -%>
<doctype version="&doctype"/>
<% attributes.reverse_merge!(:xmlns => "http://www.w3.org/1999/xhtml") if doctype =~ /^XHTML/ -%>
<%= "<html#{tag_options(attributes)}>" %>
<set-scoped xmldoctype="&doctype =~ /^XHTML/"><do param="default"/></set-scoped>
<%= "</html>" %>
</def>

<!-- empty tags should be written as <br> in HTML and <br /> in XHTML -->
<def tag="empty-tag" attrs="tag-name"><%= element(tag_name, attributes, nil, true, true) %></def>
<def tag="base"><empty-tag tag-name="base" merge/></def>
<def tag="meta"><empty-tag tag-name="meta" merge/></def>
<def tag="link"><empty-tag tag-name="link" merge/></def>
<def tag="img"><empty-tag tag-name="img" merge/></def>
<def tag="br"><empty-tag tag-name="br" merge/></def>
<def tag="hr"><empty-tag tag-name="hr" merge/></def>
<def tag="frame"><empty-tag tag-name="frame" merge/></def>
<def tag="area"><empty-tag tag-name="area" merge/></def>
<def tag="param"><empty-tag tag-name="param" merge/></def>
<def tag="col"><empty-tag tag-name="col" merge/></def>

<def tag="if-ie" attrs="version">
<%= "<!--[if #{version || 'IE'}]>" %><do param="default"/><%= "<![endif]-->" %>
</def>

<def tag="stylesheet" attrs="name, media">
<repeat with="&comma_split(name)">
Expand Down
2 changes: 1 addition & 1 deletion hobo/taglibs/rapid_plus.dryml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</if>
</th>
</with-field-names>
<th if="&all_parameters[:controls]" class="controls"/>
<th if="&all_parameters[:controls]" class="controls"></th>
</field-heading-row>
</table>
<do param="empty-message" if="empty?">No <name-for-collection lowercase/> to display</do>
Expand Down

0 comments on commit 9f22821

Please sign in to comment.