By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Some new filters

roundabout,
created on Monday, 29 April 2024, 11:36:59 (1714390619), received on Tuesday, 21 May 2024, 13:35:14 (1716298514)
Author identity: vlad <vlad.muntoiu@gmail.com>

f4fce3c59e08b617cf24eaabb97fe841c309c662

ampoule_ssg/extra_jinja.py

@@ -1,5 +1,6 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            import math
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            import datetime
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        import re
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            def init_filters(site):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                @site.filter("first_paragraph")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -11,6 +12,15 @@ def init_filters(site):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                @site.filter("rsplit")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                def rsplit(value, sep, maxsplit=-1):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    return value.rsplit(sep, maxsplit)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            @site.filter("splitlines")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            def splitlines(value, keepends=False):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                return value.splitlines(keepends)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            @site.filter("split_any")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            def split_any(value, separators, maxsplit=-1):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                return re.split("|".join(re.escape(sep) for sep in separators), value, maxsplit)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            @site.filter("split_regex")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            def split_regex(value, pattern, maxsplit=-1):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                return re.split(pattern, value, maxsplit)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                @site.filter("partition")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                def partition(value, sep):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    return value.partition(sep)