Skip to content

Commit f67fcac

Browse files
committed
Change name from templater to pyplater
1 parent 1668cd6 commit f67fcac

File tree

10 files changed

+67
-28
lines changed

10 files changed

+67
-28
lines changed

CONTRIBUTING.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Contribution Guidelines
22
=======================
33

44
Whether reporting bugs, discussing improvements and new ideas or writing
5-
extensions: Contributions to Templater are welcome! Here's how to get started:
5+
extensions: Contributions to Pyplater are welcome! Here's how to get started:
66

77
1. Check for open issues or open a fresh issue to start a discussion around
88
a feature idea or a bug
@@ -15,10 +15,10 @@ extensions: Contributions to Templater are welcome! Here's how to get started:
1515
published :)
1616

1717

18-
Philosophy of Templater
18+
Philosophy of Pyplater
1919
-----------------------
2020

21-
Templater aims to be simple and fun to use. Therefore two key values are simplicity
21+
Pyplater aims to be simple and fun to use. Therefore two key values are simplicity
2222
and elegance of interfaces and code. These values will contradict each other
2323
from time to time. In these cases , try using as little magic as possible.
2424
In any case don't forget documenting code that isn't clear at first glance.
@@ -27,7 +27,7 @@ In any case don't forget documenting code that isn't clear at first glance.
2727
Code Conventions
2828
----------------
2929

30-
In general the Templater source should always follow
30+
In general the Pyplater source should always follow
3131
`PEP 8 <http://legacy.python.org/dev/peps/pep-0008/>`_. Exceptions are allowed
3232
in well justified and documented cases. However we make a small exception
3333
concerning docstrings:
@@ -48,6 +48,6 @@ on their own lines and add an empty line after it.
4848
Version Numbers
4949
---------------
5050

51-
Templater follows the `SemVer versioning guidelines <http://semver.org/>`_.
51+
Pyplater follows the `SemVer versioning guidelines <http://semver.org/>`_.
5252
This implies that backwards incompatible changes in the API will increment
5353
the major version. So think twice before making such changes.

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
Templater
1+
Pyplater
22
=========
33

44
Build ``html`` component with python.
55

66
.. code-block:: python
77
8-
from templater import * # import all tag
8+
from pyplate import * # import all tag
99
1010
documents = html(
1111
head(
@@ -26,11 +26,11 @@ Contributing
2626
------------
2727

2828
Whether reporting bugs, discussing improvements and new ideas or writing
29-
extensions: Contributions to Templater are welcome! Here's how to get started:
29+
extensions: Contributions to Pyplater are welcome! Here's how to get started:
3030

3131
1. Check for open issues or open a fresh issue to start a discussion around
3232
a feature idea or a bug
33-
2. Fork `the repository <https://github.com/Unviray/templater/>`_ on Github,
33+
2. Fork `the repository <https://github.com/Unviray/pyplate/>`_ on Github,
3434
create a new branch off the `master` branch and start making your changes
3535
(known as `GitHub Flow <https://guides.github.com/introduction/flow/index.html>`_)
3636
3. Write a test which shows that the bug was fixed or that the feature works

bootstrap.py

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Helper for Bootstrap 4.3
33
"""
44

5-
from templater import (
5+
from pyplate import (
66
html,
77
head,
88
meta,
@@ -15,7 +15,7 @@
1515
blockquote,
1616
footer,
1717
)
18-
from templater.utils import classing
18+
from pyplate.utils import classing
1919

2020

2121
RESPONSIVE_BP = ["xs", "sm", "md", "lg", "xl"]
@@ -86,7 +86,7 @@ def container(breakpoint="", **kwargs):
8686
"""
8787

8888
if breakpoint:
89-
if breakpoint in RESPONSIVE_BP + "fluid":
89+
if breakpoint in RESPONSIVE_BP + ["fluid"]:
9090
breakpoint = "-" + breakpoint
9191
else:
9292
print(f'Breakpoint should be one of {RESPONSIVE_BP} or "fluid')
@@ -161,9 +161,9 @@ def lead(*args, **kwargs):
161161
return div(_class=c, **kwargs)(*args)
162162

163163

164-
def quote(author='', **kwargs):
164+
def quote(author="", **kwargs):
165165
class b(blockquote):
166-
TAG_NAME = 'blockquote'
166+
TAG_NAME = "blockquote"
167167

168168
def __call__(self, *args):
169169
firstChild = self.content[0](*args)
@@ -174,6 +174,45 @@ def __call__(self, *args):
174174
c = classing("blockquote", *c)
175175

176176
return b(_class=c, **kwargs)(
177-
p(_class="mb-0"),
178-
footer(_class="blockquote-footer")(author)
177+
p(_class="mb-0"), footer(_class="blockquote-footer")(author)
179178
)
179+
180+
181+
# components
182+
183+
184+
def btn(color="primary", **kwargs):
185+
tag = kwargs.pop("tag", button)
186+
outline = kwargs.pop("outline", False)
187+
size = kwargs.pop("size", "")
188+
block = kwargs.pop("block", False)
189+
190+
if tag == a:
191+
kwargs['role'] = kwargs.pop('role', 'button')
192+
kwargs['href'] = kwargs.pop('href', '#')
193+
else:
194+
kwargs['type'] = kwargs.pop('type', 'button')
195+
196+
if color:
197+
if color in COLOR_BP + ["link"]:
198+
color = "btn-outline-" + color if outline else "btn-" + color
199+
else:
200+
print(f'Color should be one of {COLOR_BP} or "link')
201+
color = ""
202+
203+
if size:
204+
if size in ('sm', 'lg'):
205+
size = "btn-" + size
206+
else:
207+
print(f'Size should be one of ["sm", "lg"]')
208+
size = ""
209+
210+
if block:
211+
block = "btn-block"
212+
else:
213+
block = ""
214+
215+
c = kwargs.pop("_class", [])
216+
c = classing("btn", color, size, block, *c)
217+
218+
return tag(_class=c, **kwargs)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
templater
2+
pyplate
33
=========
44
55
Build html component with python.
@@ -8,7 +8,7 @@
88
99
Usage example:
1010
11-
>>> from templater import h1
11+
>>> from pyplate import h1
1212
>>> title = h1("title")
1313
>>> title.render()
1414
<h1>title</h1>

templater/tag.py renamed to pyplater/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
templater.tag
2+
pyplate.tag
33
=============
44
55
Include all tags.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
templater.utils
2+
pyplate.utils
33
===============
44
5-
Utilities in templater.
5+
Utilities in pyplate.
66
"""
77

88
from typing import Iterable

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline-quotes=double
55

66
[tool:pytest]
77
addopts =
8-
--cov templater --cov-report term-missing --cov-report xml:coverage.xml
8+
--cov pyplate --cov-report term-missing --cov-report xml:coverage.xml
99
--verbose
1010
testpaths = tests
1111
norecursedirs =

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import find_packages, setup
44

5-
from templater import __version__
5+
from pyplate import __version__
66

77

88
def read(fname):
@@ -11,7 +11,7 @@ def read(fname):
1111

1212

1313
setup(
14-
name="templater",
14+
name="pyplate",
1515
version=__version__,
1616
packages=find_packages(exclude=["tests"]),
1717
zip_safe=True,
@@ -22,7 +22,7 @@ def read(fname):
2222
long_description=read('README.rst'),
2323
license="MIT license",
2424
keywords="html component react angular vue javascript js nodejs node",
25-
url="https://github.com/Unviray/templater",
25+
url="https://github.com/Unviray/pyplate",
2626
python_requires=">=3.6",
2727
classifiers=[
2828
"Development Status :: 2 - Pre-Alpha",

tests/test_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from templater.tag import Element
2-
from templater import _input, a, button, div, em, h1, html, hr, li, ul
1+
from pyplate.tag import Element
2+
from pyplate import _input, a, button, div, em, h1, html, hr, li, ul
33

44

55
def test_main():

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from templater.utils import classing
1+
from pyplate.utils import classing
22

33

44
def test_classing():

0 commit comments

Comments
 (0)