Browse Source

Merge pull request #117 from vinilios/hyde

---

Added a helper method in Expando class to ease up non existing keys handling.
Some improvements in LessCSSPlugin to be able to build complex less projects (such as twitter bootstrap)
main
Lakshmi Vyasarajan 13 years ago
parent
commit
287042b2d5
2 changed files with 25 additions and 4 deletions
  1. +19
    -4
      hyde/ext/plugins/less.py
  2. +6
    -0
      hyde/model.py

+ 19
- 4
hyde/ext/plugins/less.py View File

@@ -22,12 +22,22 @@ class LessCSSPlugin(CLTransformer):
def executable_name(self):
return "lessc"

def _should_parse_resource(self, resource):
"""
Check user defined
"""
return getattr(resource, 'meta', {}).get('parse', True)

def _should_replace_imports(self, resource):
return getattr(resource, 'meta', {}).get('uses_template', True)

def begin_site(self):
"""
Find all the less css files and set their relative deploy path.
"""
for resource in self.site.content.walk_resources():
if resource.source_file.kind == 'less':
if resource.source_file.kind == 'less' and \
self._should_parse_resource(resource):
new_name = resource.source_file.name_without_extension + ".css"
target_folder = File(resource.relative_deploy_path).parent
resource.relative_deploy_path = target_folder.child(new_name)
@@ -37,8 +47,11 @@ class LessCSSPlugin(CLTransformer):
Replace @import statements with {% include %} statements.
"""

if not resource.source_file.kind == 'less':
if not resource.source_file.kind == 'less' or not \
self._should_parse_resource(resource) or not \
self._should_replace_imports(resource):
return text

import_finder = re.compile(
'^\\s*@import\s+(?:\'|\")([^\'\"]*)(?:\'|\")\s*\;\s*$',
re.MULTILINE)
@@ -73,7 +86,8 @@ class LessCSSPlugin(CLTransformer):
Read the generated file and return the text as output.
Set the target path to have a css extension.
"""
if not resource.source_file.kind == 'less':
if not resource.source_file.kind == 'less' or not \
self._should_parse_resource(resource):
return

supported = [
@@ -82,7 +96,8 @@ class LessCSSPlugin(CLTransformer):
("compress", "x"),
"O0",
"O1",
"O2"
"O2",
"include-path="
]

less = self.app


+ 6
- 0
hyde/model.py View File

@@ -81,6 +81,12 @@ class Expando(object):
result[k] = v
return result

def get(self, key, default=None):
"""
Dict like get helper method
"""
return self.__dict__.get(key, default)


class Context(object):
"""


Loading…
Cancel
Save