diff --git a/hamlpy/nodes.py b/hamlpy/nodes.py
index a5e7e4a..b286825 100644
--- a/hamlpy/nodes.py
+++ b/hamlpy/nodes.py
@@ -18,6 +18,12 @@
except ImportError, e:
_markdown_available = False
+try:
+ from sassin import compile_with_scss as sass_compile
+ _sass_available = True
+except ImportError, e:
+ _sass_available = False
+
class NotAvailableError(Exception):
pass
@@ -45,6 +51,8 @@ class NotAvailableError(Exception):
MARKDOWN_FILTER = ':markdown'
CDATA_FILTER = ':cdata'
PYGMENTS_FILTER = ':highlight'
+SCSS_FILTER = ':scss'
+SASS_FILTER = ':sass'
ELEMENT_CHARACTERS = (ELEMENT, ID, CLASS)
@@ -111,6 +119,9 @@ def create_node(haml_line):
if stripped_line == MARKDOWN_FILTER:
return MarkdownFilterNode(haml_line)
+ if stripped_line == SASS_FILTER:
+ return SassFilterNode(haml_line)
+
return PlaintextNode(haml_line)
class TreeNode(object):
@@ -604,3 +615,20 @@ def _render(self):
self.before += markdown( ''.join(lines))
else:
self.after = self.render_newlines()
+
+class SassFilterNode(FilterNode):
+ def _render(self):
+ if self.children:
+ if not _sass_available:
+ raise NotAvailableError("Markdown is not available")
+
+ self.before = '\n'
+ indent_offset = len(self.children[0].spaces)
+ text = ''.join(''.join([c.spaces[indent_offset:], c.haml, c.render_newlines()]) for c in self.children)
+ self.before += sass_compile(text)
+ else:
+ self.after = self.render_newlines()
diff --git a/hamlpy/test/templates/filtersSass.hamlpy b/hamlpy/test/templates/filtersSass.hamlpy
new file mode 100644
index 0000000..3a15ce5
--- /dev/null
+++ b/hamlpy/test/templates/filtersSass.hamlpy
@@ -0,0 +1,11 @@
+:sass
+ $highlight: #9F2
+ /* our special border
+ @mixin big-border
+ border: 3px solid $highlightcolor
+ #main,
+ #another_main
+ font:
+ color: $highlight
+ @include big-border
+
diff --git a/hamlpy/test/templates/filtersSass.html b/hamlpy/test/templates/filtersSass.html
new file mode 100644
index 0000000..76e92f3
--- /dev/null
+++ b/hamlpy/test/templates/filtersSass.html
@@ -0,0 +1,8 @@
+
\ No newline at end of file