Syntax

Description: A misc Function is defined as a built-in helper Function relating to miscellaneous activity.

ctr('<#selector>', {
<...>: <function>(<...>)
})
<#selector>:
<...>: <function>(<...>)
<#selector> {
<prop>: <value>;
}

Notes

Last

Description: Returns the last value in the given List.

Edit
ctr('.test', {
width: 200px
font-size: unit(last(1 2 3), px)
})
.test:
width: 200px
font-size: unit(last(1 2 3), px)
.test {
width: 200px;
font-size: 3px;
}
ctr('.test', {
  width: 200px
  font-size: unit(last(1 2 3), px)
})
.test {
  width: 200px;
  font-size: 3px;
}
.test:
  width: 200px
  font-size: unit(last(1 2 3), px)

Notes

Length

Description: Returns the length of a given List.

Edit
ctr('.test', {
width: 200px
font-size: unit(length((1 2 3 4)), px)
})
.test:
width: 200px
font-size: unit(length((1 2 3 4)), px)
.test {
width: 200px;
font-size: 4px;
}
ctr('.test', {
  width: 200px
  font-size: unit(length((1 2 3 4)), px)
})
.test {
  width: 200px;
  font-size: 4px;
}
.test:
  width: 200px
  font-size: unit(length((1 2 3 4)), px)

Notes

Lookup

Description: Looks up a variable with a given name, passed as a String, and returns null if the variable is undefined.

Edit
font-size-1 = 10px
font-size-2 = 20px
font-size-3 = 30px
for i in 1..3
.test-{i}
ctr({
width: 200px
font-size: lookup('font-size-' + i)
})
.test-1 {
width: 200px;
font-size: 10px;
}
.test-2 {
width: 200px;
font-size: 20px;
}
.test-3 {
width: 200px;
font-size: 30px;
}
font-size-1 = 10px
font-size-2 = 20px
font-size-3 = 30px

for i in 1..3
  .test-{i}
    ctr({
      width: 200px
      font-size: lookup('font-size-' + i)
    })
.test-1 {
  width: 200px;
  font-size: 10px;
}
.test-2 {
  width: 200px;
  font-size: 20px;
}
.test-3 {
  width: 200px;
  font-size: 30px;
}

Notes

Replace

Description: Returns a String with all matches of pattern replaced by replacement in given val.

Edit
ctr('.test', {
width: 200px
color: replace(i, e, griin)
})
.test:
width: 200px
color: replace(i, e, griin)
.test {
width: 200px;
color: #008000;
}
ctr('.test', {
  width: 200px
  color: replace(i, e, griin)
})
.test {
  width: 200px;
  color: #008000;
}
.test:
  width: 200px
  color: replace(i, e, griin)

Notes

S

Description: The S() function is similar to unquote() in that it returns a Literal node. It also accepts a format String much like C’s sprintf(). Currently the only specifier is %s.

Edit
ctr('.test', {
width: 200px
transform: s("translate(%s, %s)", 10px, 20px)
})
.test:
width: 200px
transform: s("translate(%s, %s)", 10px, 20px)
.test {
width: 200px;
transform: translate(10px, 20px);
}
ctr('.test', {
  width: 200px
  transform: s("translate(%s, %s)", 10px, 20px)
})
.test {
  width: 200px;
  transform: translate(10px, 20px);
}
.test:
  width: 200px
  transform: s("translate(%s, %s)", 10px, 20px)

Notes

Substr

Description: The substr() method returns the characters in a String beginning at the specified location through the specified number of characters.

Edit
ctr('.test', {
width: 200px
background: substr(substr(dredd, 1), 0, 3)
})
.test:
width: 200px
background: substr(substr(dredd, 1), 0, 3)
.test {
width: 200px;
background: #f00;
}
ctr('.test', {
  width: 200px
  background: substr(substr(dredd, 1), 0, 3)
})
.test {
  width: 200px;
  background: #f00;
}
.test:
  width: 200px
  background: substr(substr(dredd, 1), 0, 3)

Notes

Unit

Description: Returns a String for the type of unit or an empty String, or assign the given type without unit conversion.

Edit
ctr('.test', {
width: 200px
font-size: unit(15%, px)
})
.test:
width: 200px
font-size: unit(15%, px)
.test {
width: 200px;
font-size: 15px;
}
ctr('.test', {
  width: 200px
  font-size: unit(15%, px)
})
.test {
  width: 200px;
  font-size: 15px;
}
.test:
  width: 200px
  font-size: unit(15%, px)

Notes