-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved classes Embed(), FieldSet() and Figure() from html/construct.py…
… to html/tags/
- Loading branch information
1 parent
49fc713
commit 4c93e40
Showing
11 changed files
with
145 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Module for constructing <embed> tag.""" | ||
|
||
from ...templates.html.tags import embed_tag | ||
|
||
|
||
class Embed(object): | ||
"""Class for constructing embed tag. | ||
Args: | ||
height (str): Specifies the height of the embedded content (in pixels). | ||
width (str): Specifies the width of the embedded content (in pixels). | ||
src (str): Specifies the address of the external file to embed. | ||
type (str): Specifies the media type of the embedded content. | ||
.. versionadded:: 0.2.0 | ||
""" | ||
def __init__(self, height=None, width=None, src=None, type=None): | ||
self.tag = 'embed' | ||
self.values = {'height': height, | ||
'width': width, | ||
'src': src, | ||
'type': type} | ||
|
||
def construct(self): | ||
"""Returns the constructed embed tag <embed>.""" | ||
return embed_tag.render(self.values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Module for constructing <fieldset> tag.""" | ||
|
||
from ...templates.html.tags import fieldset_tag | ||
|
||
|
||
class FieldSet(object): | ||
"""Class for constructing fieldset tag. | ||
Args: | ||
disabled (bool): Specifies that a group of related form elements | ||
should be disabled. | ||
form (str): Specifies one or more forms the fieldset belongs to. | ||
name (str): Specifies a name for the fieldset. | ||
.. versionadded:: 0.2.0 | ||
""" | ||
def __init__(self, disabled=False, form=None, name=None): | ||
# TODO: Add support for inner tags. | ||
self.tag = 'fieldset' | ||
self.values = {'disabled': disabled, 'form': form, 'name': name} | ||
|
||
def construct(self): | ||
"""Returns the constructed fieldset tag <fieldset></fieldset>.""" | ||
return fieldset_tag.render(self.values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Module for constructing <figure> tag.""" | ||
|
||
from ...templates.html.tags import figure_tag | ||
|
||
|
||
class Figure(object): | ||
"""Class for constructing figure tag. | ||
Args: | ||
text (str): Specifies the figure text. (As in <figure>{text}</figure>) | ||
.. versionadded:: 0.2.0 | ||
""" | ||
def __init__(self, text=None): | ||
# TODO: Add support for inner tags. | ||
self.tag = 'figure' | ||
self.values = {'text': text} | ||
|
||
def construct(self): | ||
"""Returns the constructed figure tag <figure></figure>.""" | ||
return figure_tag.render(self.values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from ..fixtures import parametrize | ||
|
||
from korona.html.tags import Embed | ||
from korona.templates.html.tags import embed_tag | ||
|
||
|
||
@parametrize('attributes', [ | ||
({'height': '200'}), | ||
({'height': '200', 'width': '100'}), | ||
({'src': 'helloworld.swf', 'height': '200', 'width': '100'}), | ||
({'src': 'helloworld.swf', | ||
'height': '200', | ||
'width': '100', | ||
'type': 'application'}) | ||
]) | ||
def test_construct_embed_tag(attributes): | ||
"""Test for validating whether the embed tag is constructed correctly or | ||
not. | ||
""" | ||
embed = Embed(**attributes) | ||
assert embed.construct() == embed_tag.render(attributes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from ..fixtures import parametrize | ||
|
||
from korona.html.tags import FieldSet | ||
from korona.templates.html.tags import fieldset_tag | ||
|
||
|
||
@parametrize('attributes', [ | ||
({'disabled': True}), | ||
({'form': 'form1'}), | ||
({'name': 'name1'}), | ||
({'disabled': True, 'form': 'form1', 'name': 'name1'}) | ||
]) | ||
def test_construct_fieldset_tag(attributes): | ||
"""Test for validating whether the fieldset tag is constructed correctly | ||
or not. | ||
""" | ||
fieldset = FieldSet(**attributes) | ||
assert fieldset.construct() == fieldset_tag.render(attributes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from ..fixtures import parametrize | ||
|
||
from korona.html.tags import Figure | ||
from korona.templates.html.tags import figure_tag | ||
|
||
|
||
@parametrize('attributes', [ | ||
({'text': 'abcd'}) | ||
]) | ||
def test_construct_figure_tag(attributes): | ||
"""Test for validating whether the figure tag is constructed correctly or | ||
not. | ||
""" | ||
figure = Figure(**attributes) | ||
assert figure.construct() == figure_tag.render(attributes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters