Source code for score.sass._init

# Copyright © 2017 STRG.AT GmbH, Vienna, Austria
#
# This file is part of the The SCORE Framework.
#
# The SCORE Framework and all its parts are free software: you can redistribute
# them and/or modify them under the terms of the GNU Lesser General Public
# License version 3 as published by the Free Software Foundation which is in the
# file named COPYING.LESSER.txt.
#
# The SCORE Framework and all its parts are distributed without any WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. For more details see the GNU Lesser General Public
# License.
#
# If you have not received a copy of the GNU Lesser General Public License see
# http://www.gnu.org/licenses/.
#
# The License-Agreement realised between you as Licensee and STRG.AT GmbH as
# Licenser including the issue of its valid conclusion and its pre- and
# post-contractual effects is governed by the laws of Austria. Any disputes
# concerning this License-Agreement including the issue of its valid conclusion
# and its pre- and post-contractual effects are exclusively decided by the
# competent court, in whose district STRG.AT GmbH has its registered seat, at
# the discretion of STRG.AT GmbH also the competent court, in whose district the
# Licensee has his registered seat, an establishment or assets.

from score.init import ConfiguredModule
from .renderer import SassRenderer


defaults = {
    'cachedir': None,
}


[docs]def init(confdict, tpl): """ Initializes this module acoording to :ref:`our module initialization guidelines <module_initialization>` with the following configuration keys: :confkey:`cachedir` :confdefault:`None` A folder that will be used for caching rendered css files. Not strictly necessary, but will speed up the rendering proces a lot. """ conf = dict(defaults.items()) conf.update(confdict) return ConfiguredSassModule(tpl, conf['cachedir'])
[docs]class ConfiguredSassModule(ConfiguredModule): """ This module's :class:`configuration object <score.init.ConfiguredModule>`. """ def __init__(self, tpl, cachedir): super().__init__(__package__) self.tpl = tpl self.cachedir = cachedir for extension in ['scss', 'sass']: tpl.engines[extension] = self._create_renderer tpl.filetypes['text/css'].extensions.append(extension) def _create_renderer(self, tpl_conf, filetype): return SassRenderer(self, tpl_conf, filetype)