Sha256: 6b58ea053ebc7b65068e5f2a68faf138afd786a8bfe6ff2f04f6f0ebdbe9c663

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

= KingFormat

Define fields being of type date, currency or percent.  When the fields are shown
within KingList/KingForm views, their format is detected and the output is
automatically formatted. Default formats of date and currency fields can be set
and both also take te current I18n.locale into account.

KingFormat consists of two different formatting helper regions:

== Model

This is where you define the type of fields/attributes. Of course the model
should somehow respond to those method names.

  class Document
    has_money_fields :gross_total, :net_total
    has_date_fields :created_at, :date
    has_percent_fields :discount
    ...
  end

== View & Helper

Output any model value through the function strfval() to ensure a consistent output.
Further on you find select values for money-symbols and date formatting.

A simple HAML example, without hussles:

  - dl_for(current_object) do |f|
    = f.show :net_total
    = f.show :gross_total
    = f.show :date
    = f.show :discount
    = f.show :net_total, :value=>strfval(current_object, :net_total)


Copyright (c) 2009-2010 Georg Leciejewski, released under the MIT license

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
king_views-1.1.4 king_format/README.rdoc
king_views-1.1.3 king_format/README.rdoc
king_views-1.1.2 king_format/README.rdoc
king_views-1.1.1 king_format/README.rdoc
king_views-1.1.0 king_format/README.rdoc