Mercurial > piecrust2
comparison piecrust/rendering.py @ 520:bab91fcef741
bake/serve: Improve support for unicode, add slugification options.
* Add slugification options for taxonomies.
* Sort out some unicode support problems on OSX.
* Add tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 28 Jul 2015 18:34:21 -0700 |
parents | 16e705c58cae |
children | 094bdf2f7c4c |
comparison
equal
deleted
inserted
replaced
519:9d1a89cd8146 | 520:bab91fcef741 |
---|---|
164 self._raiseIfNoCurrentPass() | 164 self._raiseIfNoCurrentPass() |
165 if isinstance(source, PageSource): | 165 if isinstance(source, PageSource): |
166 pass_info = self.current_pass_info | 166 pass_info = self.current_pass_info |
167 pass_info.used_source_names.add(source.name) | 167 pass_info.used_source_names.add(source.name) |
168 | 168 |
169 def setTaxonomyFilter(self, term_value): | 169 def setTaxonomyFilter(self, term_value, *, needs_slugifier=False): |
170 if not self.page.route.is_taxonomy_route: | 170 if not self.page.route.is_taxonomy_route: |
171 raise Exception("The page for this context is not tied to a " | 171 raise Exception("The page for this context is not tied to a " |
172 "taxonomy route: %s" % self.uri) | 172 "taxonomy route: %s" % self.uri) |
173 | 173 |
174 slugifier = None | |
175 if needs_slugifier: | |
176 slugifier = self.page.route.slugifyTaxonomyTerm | |
174 taxonomy = self.app.getTaxonomy(self.page.route.taxonomy_name) | 177 taxonomy = self.app.getTaxonomy(self.page.route.taxonomy_name) |
178 | |
175 flt = PaginationFilter(value_accessor=page_value_accessor) | 179 flt = PaginationFilter(value_accessor=page_value_accessor) |
176 flt.addClause(HasTaxonomyTermsFilterClause( | 180 flt.addClause(HasTaxonomyTermsFilterClause( |
177 taxonomy, term_value, self.page.route.slugifyTaxonomyTerm)) | 181 taxonomy, term_value, slugifier)) |
178 self.pagination_filter = flt | 182 self.pagination_filter = flt |
179 | 183 |
180 is_combination = isinstance(term_value, tuple) | 184 is_combination = isinstance(term_value, tuple) |
181 self.custom_data = { | 185 self.custom_data = { |
182 taxonomy.term_name: term_value, | 186 taxonomy.term_name: term_value, |