From 2cbeb25abea3d8ae4987b906a175090511eed6c4 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Fri, 23 Mar 2012 11:55:38 -0400 Subject: [PATCH] added current-time and current-date sass functions --- lib/compass/sass_extensions/functions/env.rb | 11 +++++++++++ test/fixtures/stylesheets/envtest/css/env.css | 4 ++++ test/fixtures/stylesheets/envtest/sass/env.scss | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/lib/compass/sass_extensions/functions/env.rb b/lib/compass/sass_extensions/functions/env.rb index ae9cd66d..849a2995 100644 --- a/lib/compass/sass_extensions/functions/env.rb +++ b/lib/compass/sass_extensions/functions/env.rb @@ -1,5 +1,16 @@ module Compass::SassExtensions::Functions::Env + def compass_env Sass::Script::String.new((options[:compass][:environment] || "development").to_s) end + + def current_time(format) + time = Time.now.strftime(format.to_s) + + Sass::Script::String.new(time.to_s) + end + + alias :current_date :current_time + + end diff --git a/test/fixtures/stylesheets/envtest/css/env.css b/test/fixtures/stylesheets/envtest/css/env.css index 1c08a273..aa8a733f 100644 --- a/test/fixtures/stylesheets/envtest/css/env.css +++ b/test/fixtures/stylesheets/envtest/css/env.css @@ -1,2 +1,6 @@ .env { env: <%= options[:environment] %>; } +.time { + time: "<%= Time.now.strftime("%F") %>"; } +.date { + date: "<%= Time.now.strftime("%F") %>"; } \ No newline at end of file diff --git a/test/fixtures/stylesheets/envtest/sass/env.scss b/test/fixtures/stylesheets/envtest/sass/env.scss index e88f6fbe..60e8a69c 100644 --- a/test/fixtures/stylesheets/envtest/sass/env.scss +++ b/test/fixtures/stylesheets/envtest/sass/env.scss @@ -1,3 +1,11 @@ .env { env: compass-env(); } + +.time { + time: current-time("%F"); +} + +.date { + date: current-date("%F"); +} \ No newline at end of file