Source code for score.css._init
# Copyright © 2015-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 parse_bool, parse_list, ConfiguredModule
defaults = {
'tpl.extensions': ['css'],
'tpl.register_minifier': False,
}
[docs]def init(confdict, tpl):
"""
Initializes this module acoording to :ref:`our module initialization
guidelines <module_initialization>` with the following configuration keys:
:confkey:`tpl.register_minifier` :confdefault:`False`
Whether css assets should be minified. Setting this to `True` will
register a :ref:`postprocessor <tpl_file_types>` for the 'text/css' file
type in :mod:`score.tpl`.
"""
conf = dict(defaults.items())
conf.update(confdict)
filetype = tpl.filetypes['text/css']
if parse_bool(conf['tpl.register_minifier']):
import csscompressor
filetype.postprocessors.append(csscompressor.compress)
filetype.extensions.extend(parse_list(conf['tpl.extensions']))
return ConfiguredCssModule(tpl)