Example #1
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from htbuilder import div, ul, li, img, styles, classes, fonts
from htbuilder.units import px
from htbuilder.funcs import rgba, rgb

image_paths = [
    "http://myimages.com/foo1.jpg",
    "http://myimages.com/foo2.jpg",
    "http://myimages.com/foo3.jpg",
]

html_element = div(id="container")(ul(_class="image-list")([
    li(img(src=image_path, _class="large-image")) for image_path in image_paths
]))

print(html_element)

bottom_margin = 10

s = styles(
    color="black",
    font_family=fonts("Comic Sans", "sans"),
    margin=px(0, 0, bottom_margin, 0),
    box_shadow=[
        (0, 0, px(10), rgba(0, 0, 0, 0.1)),
        (0, 0, "2px", rgb(0, 0, 0)),
    ],
)
Example #2
0
def image(src_as_string, **style):
    return img(src=src_as_string, style=styles(**style))
Example #3
0
 def test_self_closing(self):
     dom = img(src="foo")
     self.assertEqual(
         str(dom),
         normalize_whitespace('<img src="foo"/>'),
     )