New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

pytemplates

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pytemplates - pypi Package Compare versions

Comparing version
0.1
to
0.1.1
+1
-1
PKG-INFO
Metadata-Version: 1.0
Name: pytemplates
Version: 0.1
Version: 0.1.1
Summary: Lightweight Python HTML Template Engine

@@ -5,0 +5,0 @@ Home-page: http://bitbucket.com/zeid/pytemplates

# Copyright (c) 2013 Zeid Zabaneh
# PyTemplates is distributed under the terms of the GNU General Public License
from pytemplates.utils import escape
from pytemplates.utils import render_empty_tag
from pytemplates.utils import render_content
from utils import escape
from utils import render_empty_tag
from utils import render_content
from utils import t
from utils import Tag
from collections import defaultdict

@@ -21,33 +24,2 @@ import re

def tag(arg, *args, **kwargs):
_name = re.compile('^(\w+?)(?:\.|#|\:|$)')
_classes = re.compile('\.([a-zA-Z0-9\-_]+)')
_id = re.compile('\#(\w+)')
_unnamed_attrs = re.compile('\:(\w+)')
_named_attrs = re.compile('\[(\w+)="(.+)"\]')
name = _name.findall(arg)[0]
attributes = dict()
tag_id = _id.findall(arg)
tag_classes = _classes.findall(arg)
tag_unnamed_attrs = _unnamed_attrs.findall(arg)
tag_named_attrs = _named_attrs.findall(arg)
unnamed_attributes = tag_unnamed_attrs
named_attributes = {k: v for k, v in tag_named_attrs}
if tag_id:
attributes['id'] = tag_id[0]
classes = ' '.join(tag_classes)
if classes:
attributes['_class'] = classes
attributes.update(named_attributes)
attributes.update(kwargs)
unnamed_attributes += args
return Tag(name, *unnamed_attributes, **attributes)
def render(variable, *args):

@@ -60,13 +32,2 @@ if 'safe' in args:

class Tag(object):
def __init__(self, tag_name, *args, **kwargs):
self.tag_name = tag_name
self.attributes = {k: v for k, v in kwargs.iteritems()}
self.unnamed_attributes = [v for v in args]
for k in self.attributes:
if k[0] == '_':
self.attributes[k[1:]] = self.attributes[k]
del(self.attributes[k])
class Blocks(object):

@@ -73,0 +34,0 @@ pass

# Copyright (c) 2013 Zeid Zabaneh
# PyTemplates is distributed under the terms of the GNU General Public License
import re
class Tag(object):
def __init__(self, tag_name, *args, **kwargs):
self.tag_name = tag_name
self.attributes = {k: v for k, v in kwargs.iteritems()}
self.unnamed_attributes = [v for v in args]
for k in self.attributes:
if k[0] == '_':
self.attributes[k[1:]] = self.attributes[k]
del(self.attributes[k])
def escape(s):

@@ -15,2 +28,32 @@ s = str(s)

def t(arg, *args, **kwargs):
_name = re.compile('^(\w+?)(?:\.|#|\:|$)')
_classes = re.compile('\.([a-zA-Z0-9\-_]+)')
_id = re.compile('\#(\w+)')
_unnamed_attrs = re.compile('\:(\w+)')
_named_attrs = re.compile('\[(\w+)="(.+)"\]')
name = _name.findall(arg)[0]
attributes = dict()
tag_id = _id.findall(arg)
tag_classes = _classes.findall(arg)
tag_unnamed_attrs = _unnamed_attrs.findall(arg)
tag_named_attrs = _named_attrs.findall(arg)
unnamed_attributes = tag_unnamed_attrs
named_attributes = {k: v for k, v in tag_named_attrs}
if tag_id:
attributes['id'] = tag_id[0]
classes = ' '.join(tag_classes)
if classes:
attributes['_class'] = classes
attributes.update(named_attributes)
attributes.update(kwargs)
unnamed_attributes += args
return Tag(name, *unnamed_attributes, **attributes)
def render_attributes(attributes={}, unnamed_attributes=[]):

@@ -32,3 +75,2 @@ '''

def fix_tag(tag):
from pytemplates import tag as t
if type(tag) == set:

@@ -70,4 +112,2 @@ _arg = ''

'''
from pytemplates import Tag
tag = fix_tag(tag)

@@ -74,0 +114,0 @@

@@ -13,3 +13,3 @@ PyTemplates is a lightweight HTML template engine written in Python.

# Installation Instructions
To install PyTemplates, run **python setup.py install**
To install PyTemplates, run **pip install pytemplates** or download the package manually and run **python setup.py install**

@@ -132,2 +132,14 @@ To use the Django plugin, import the render\_to\_response function included in the django\_plugin module and use it in your views.

## Includes
You can include any external file with an include statement. This will render that file wherever you put the include statement. This can be used to include embedded javascript code, css code, or raw html code, or any other text you would like to include in your templates.
```python
from pytemplates import Template
class MyTemplate(Template):
def template(self, c, b, m):
template = [{'div'}, self.include('some_external_file.html')]
return template
```
# How to Create a Template

@@ -154,2 +166,2 @@ Templates in PyTemplates extend a base Template class and must define a template method.

return template
```
```
from distutils.core import setup
setup(name='pytemplates',
version='0.1',
version='0.1.1',
description='Lightweight Python HTML Template Engine',

@@ -5,0 +5,0 @@ author='Zeid Zabaneh',