12345678910111213141516171819202122232425262728293031 |
- # Copyright 2021 The Chromium Authors. All rights reserved.
- # Use of this source code is governed by a BSD-style license that can be
- # found in the LICENSE file.
- import re
- from style_variable_generator.css_generator import CSSStyleGenerator
- class TSStyleGenerator(CSSStyleGenerator):
- '''Generator for TS Variables'''
- @staticmethod
- def GetName():
- return 'TS'
- def Render(self):
- return self.ApplyTemplate(self, 'templates/ts_generator.tmpl',
- self.GetParameters())
- def GetParameters(self):
- params = CSSStyleGenerator.GetParameters(self)
- params['include_style_sheet'] = self.generator_options.get(
- 'include_style_sheet', 'false') == 'true'
- return params
- def GetFilters(self):
- filters = CSSStyleGenerator.GetFilters(self)
- filters['to_ts_var_name'] = self.ToTSVarName
- return filters
- def ToTSVarName(self, model_name):
- return re.sub(r'[\.\-]', '_', model_name.upper())
|