mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Color literal.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@253 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
3671fe1a4a
commit
808dcec05f
3 changed files with 12 additions and 3 deletions
|
@ -1,8 +1,15 @@
|
|||
require 'sass/constant/string'
|
||||
require 'sass/constant/number'
|
||||
require 'sass/constant/color'
|
||||
|
||||
module Sass::Constant
|
||||
class Operation
|
||||
# The regular expression matching numbers.
|
||||
NUMBER = /^[0-9]*\.?[0-9]+$/
|
||||
|
||||
# The regular expression matching colors.
|
||||
COLOR = /^\#(#{"[0-9a-f]" * 3}|#{"[0-9a-f]" * 6})/
|
||||
|
||||
def initialize(operand1, operand2=nil, operator=nil)
|
||||
@operand1 = parse(operand1)
|
||||
@operand2 = parse(operand2) if operand2
|
||||
|
@ -11,8 +18,10 @@ module Sass::Constant
|
|||
|
||||
def parse(value)
|
||||
case value
|
||||
when /^[0-9]*\.?[0-9]+$/ # Number with one or zero decimal points
|
||||
when NUMBER
|
||||
Sass::Constant::Number.new(value)
|
||||
when COLOR
|
||||
Sass::Constant::Color.new(value)
|
||||
else
|
||||
Sass::Constant::String.new(value)
|
||||
end
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#main { width: 500px; background-color: #000; color: #fff; }
|
||||
#main { width: 500px; background-color: #000; color: #ffffaf; }
|
||||
#main #sidebar { background-color: #00ff98; num-normal: 10; num-dec: 10.2; num-dec0: 99; num-neg: -10; esc: 10+12; }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
!width = 500px
|
||||
!color = #00ff98
|
||||
!main_text = #fff
|
||||
!main_text = #ffa
|
||||
!num = 10
|
||||
!dec = 10.2
|
||||
!dec_0 = 99.0
|
||||
|
|
Loading…
Add table
Reference in a new issue