<% tag ||= scope.in_form ? "input" : "view"; no_edit ||= "skip" %> <% field_name = this_field_name input_attrs = {:no_edit => no_edit} if tag == "input" && no_edit == "disable" -%> <%= field_name %>
<%= this_field_help %>
<%= scope.nil_view || "(Not Available)" %> <%= element("table", attributes, all_parameters.default) %> <% field_tag ||= "view" %> <% element "table", attributes - attrs_for(:with_fields) do %> <%= this.member_class.try.view_hints.try.field_name(scope.field_name) if scope %> Edit <% end %> <%= res = 'var hoboParts = {};' # FIXME: This should interrogate the model-router - not the models unless Hobo::Model.all_models.empty? # Tell JS code how to pluralize names, unless they follow the simple rule names = Hobo::Model.all_models.map do |m| m = m.name.underscore "#{m}: '#{m.pluralize}'" unless m.pluralize == m + 's' end.compact res << "var pluralisations = {#{names * ', '}}; " end base = [base_url, subsite].compact.join("/") res << "urlBase = '#{base}'; hoboPagePath = '#{view_name}'" if protect_against_forgery? res << "; formAuthToken = { name: '#{request_forgery_protection_token}', value: '#{form_authenticity_token}' }" end res %> <%= if this.nil? nil_view unless if_present else if this.is_a?(Array) count elsif this.is_a?(Class) type_name(attributes) elsif (name_attr = this.class.try.name_attribute) && can_view?(this, name_attr) view(merge_attrs(attributes, {:field => name_attr})) elsif can_view?(this) h this.to_s end end %> <%= type ||= (this if this.is_a?(Class)) || this.try.member_class || this.class name = type.respond_to?(:view_hints) ? type.view_hints.model_name : type.name name = dasherize ? name.underscore.dasherize : name.titleize name = name.pluralize if plural name = name.downcase if lowercase name %> <%= if (attr = this.try.origin_attribute) name = attr.to_s name = dasherize ? name.underscore.dasherize : name.titleize name = name.singularize if singular name = name.downcase if lowercase name else type_name(:plural => !singular, :lowercase => lowercase, :dasherize => dasherize) end %> <%= content = parameters.default params = self.query_params.merge(params || HashWithIndifferentAccess.new) if query_params if href || attributes[:name] # Regular link href += "?" + params.map { |n, v| "#{n}=#{v}" }.join('&') if !params.blank? element(:a, attributes.update(:href => href), content) else target = to || this if target.nil? Hobo::Dryml.last_if = false nil_view elsif action == "new" # Link to a new object form new_record = target.new new_record.set_creator(current_user) href = object_url(target, "new", params._?.merge(:subsite => subsite)) if href && (force || can_create?(new_record)) new_class_name = if target.respond_to?(:proxy_reflection) target.proxy_reflection.klass.name else target.name end add_classes!(attributes, "new-#{new_class_name.underscore}-link") content = "New #{new_class_name.titleize}" if content.blank? Hobo::Dryml.last_if = true element(:a, attributes.update(:href => href), content) else Hobo::Dryml.last_if = false "" end else # Link to an existing object content = name if content.blank? href = object_url(target, action, (params || {}).merge(:subsite => subsite)) if href.nil? # This target is registered with ModelRouter as not linkable content else css_class = target.try.origin_attribute || target.class.name.underscore.dasherize add_classes!(attributes, "#{css_class}-link") href.sub!(/\?|$/, ".#{format}\\0") unless format.blank? # Set default link text if none given element(:a, attributes.update(:href => href), content) end end end %> <%= raise HoboError, "view of non-viewable field '#{this_field}' of #{this_parent.typed_id rescue this_parent}" unless can_view? res = if this.nil? && if_blank.nil? this_type.is_a?(Class) && this_type <= String ? "" : nil_view elsif (refl = this_field_reflection) && refl.macro == :has_many collection_view(attributes) else view_tag = find_polymorphic_tag("view") if view_tag == "view" # i.e. it didn't find a type specific tag if this.respond_to?(:to_html) this.to_html(scope.xmldoctype) else this.to_s end else attrs = add_classes(attributes, "view", type_and_field._?.dasherize, model_id_class) view_attrs = attrs_for(view_tag) the_view = send(view_tag, attrs & view_attrs) the_view = if_blank if if_blank && the_view.blank? truncate = 30 if truncate == true the_view = self.truncate(the_view, truncate.to_i) if truncate the_view = the_view.strip if no_wrapper the_view else wrapper = if inline :span elsif block || this.is_a?(HoboFields::Text) :div else :span end element(wrapper, attrs - view_attrs, the_view) end end end Hobo::Dryml.last_if = !res.blank? res %> <%= this.empty? ? "(none)" : context_map { a }.join(", ") %> <%= this && (format ? this.strftime(format) : this.to_s(:long)) %> <%= this && (format ? this.strftime(format) : this.to_s(:long)) %> <%= this && (format ? this.strftime(format) : this.to_s(:long)) %> <%= format ? format % this : this.to_s %> <%= if !(this.class == String) && this.respond_to?(:to_html) # workaround for Maruku which adds String#to_html : ( this.to_html(scope.xmldoctype) else h(this).gsub("\n", "") end %> <%= this ? 'Yes' : 'No' %> <%= raise Exception.new("asked for count of a string") if this.is_a?(String) c = this.try.to_int || this.try.total_entries || (this.try.loaded? && this.try.length) || this.try.count || this.try.length label ||= if this.is_a?(Class) this.name elsif (attr = this.try.origin_attribute) attr.to_s.singularize else this.member_class.name end.titleize label = label.downcase if lowercase Hobo::Dryml.last_if = c > 0 if if_any if if_any && c == 0 "" else main = label.blank? ? c : pluralize(c, label) if prefix.in? %w(are is) p = c == 1 ? "is" : "are" p + ' ' + main.to_s else main end end %> <% name ||= Hobo.current_theme -%> <%= "#{titleize ? 'Y' : 'y'}ou#{' have' if have}#{' are' if are}#{' do' if do_}" %><%= "#{' has' if have}#{' is' if are}#{' does' if do_}" %> your <%= n = name; n.ends_with?('s') ? "#{n}'" : "#{n}'s" %> Your <%= n = name; n.ends_with?('s') ? "#{n}'" : "#{n}'s" %> <%= (word =~ /^[aeiou]/i ? "an " : "a ") + word %> <%= (word =~ /^[aeiou]/i ? "An " : "A ") + word %> <%= this.join(join || ", ") %>