phpsass
phpsass copied to clipboard
Mixin parameters inside @font-face
This mixin returns the same output for every call despite passed arguments are different
@mixin webfont($fontname){
@font-face{
font-family: $fontname;
}
}
@include webfont('first-fontname');
@include webfont('second-fontname');
Renders as:
@font-face { font-family: 'first-fontname';}
@font-face { font-family: 'first-fontname';}
I really don't now what is wrong with scss2Token function but it returns null in the second case
Hi, I ran into the same problem and found a possible fix. The problem lay in SassDirectiveNode which, when parsed, modified itself instead of returning a clone. If the directive was used more than once (i.e. when in a mixin), then the second time it was used it was already compiled with the first context.
I don't know Git, so I'll just paste the diff.
tree/SassDirectiveNode.php
@@ -44,11 +44,12 @@
*/
public function parse($context)
{
- $this->token->source = self::interpolate_nonstrict($this->token->source, $context);
+ $node = clone $this;
+ $node->token->source = self::interpolate_nonstrict($this->token->source, $context);
- $this->children = $this->parseChildren($context);
+ $node->children = $this->parseChildren($context);
- return array($this);
+ return array($node);
}
/**
@@ -66,6 +67,16 @@
}
/**
+ * @see parse
+ */
+ public function __clone()
+ {
+ parent::__clone();
+ $this->token = clone $this->token;
+ }
+
+ /**
* Returns a value indicating if the token represents this type of node.
* @param object $token token
* @return boolean true if the token represents this type of node, false if not