Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc time_for in Spanish readme #346

Merged
merged 1 commit into from Aug 26, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.es.rdoc
Expand Up @@ -1157,6 +1157,38 @@ También podés pasarle un nombre de archivo:
"guardalo!"
end

=== Fecha y Hora

Sinatra pone a tu disposición el helper +time_for+, que genera un objeto +Time+
a partir del valor que recibe como argumento. Este valor puede ser un
+String+, pero también es capaz de convertir objetos +DateTime+, +Date+ y de
otras clases similares.

get '/' do
pass if Time.now > time_for('Dec 23, 2012')
"todavía hay tiempo"
end

Este método es usado internamente por métodos como +expires+ y +last_modified+,
entre otros. Por lo tanto, es posible extender el comportamiento de estos
métodos sobreescribiendo +time_for+ en tu aplicación:

helpers do
def time_for(value)
case value
when :ayer then Time.now - 24*60*60
when :mañana then Time.now + 24*60*60
else super
end
end
end

get '/' do
last_modified :ayer
expires :mañana
"hola"
end

=== Buscando los Archivos de las Plantillas

El helper <tt>find_template</tt> se utiliza para encontrar los archivos de las
Expand Down