Skip to content

Commit

Permalink
variable recognition function code written and tested
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikJoreteg committed Dec 30, 2009
1 parent 41ca17a commit 9882516
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
9 changes: 9 additions & 0 deletions model/sass.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@
return result;
}

function isVar(line){
if(REFind("^![0-9a-zA-Z_-]+( +)?=( +)?\S", trim(arguments.line))){
return true;
}
else{
return false;
}
}

function buildSelectorString(selector_array){
var j = 1;
var result = '';
Expand Down
5 changes: 4 additions & 1 deletion static/test.sass
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
!padding = "5px"


h1
height: 118px
margin-top: 1em
Expand All @@ -17,4 +20,4 @@ h1
background-color: #FFF

h3
other: 3px
padding: 5px
28 changes: 28 additions & 0 deletions test/sassTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,34 @@ component extends="coldbox.system.testing.BasePluginTest" {
}

}

function test_isVar(){
var i = 1;
var j = 1;
var valid_vars = [
"!_test = blah",
"!test = 5",
"!meeh=4"
];

var invalid_vars = [
"test = blah",
" !test = ",
" !meeh: 4px"
];

// test the valid ones
for(i = 1; i LTE arrayLen(valid_vars); i = i + 1){
debug(valid_vars[i]);
assertTrue(sass.isVar(valid_vars[i]));
}

// test the invalid ones
for(j = 1; j LTE arrayLen(invalid_vars); j = j + 1){
debug(invalid_vars[j]);
assertFalse(sass.isVar(invalid_vars[j]));
}
}

function test_sass2css(){

Expand Down

0 comments on commit 9882516

Please sign in to comment.