Skip to main content

Lightweight support for managing metadata on webpages.

Project description

htmlmeta_hub

Build Status: Python package

htmlmeta_hub offers lightweight support for managing metadata on webpages.

This package simply and conveniently manages a dict of "metadata"", and renders it appropriately.

There are helpers for the Pyramid framework which will attach the metdata object to a request, allowing you to build up metadata throughtout the request cycle and then finally render.

A typical way to use this package in the Pyramid framework:

Include this package in your application's __init__.py:

def main(global_config, **settings):
	...
	# custom htmlmeta
	config.include("htmlmeta_hub.pyramid_helpers")

If you are using "class based views", you can set some default metadata in a core handler:

class Handler(object):
	def __init__(self,request):
		self.request = request
		# set some defaults
		self.reqesut.htmlmeta.set_many(\
			title="MyApp",
			description="awesome",
			keywords="fun!",
		)

and then you can add specific metadata in each view's handler:

class ContentPage(Handler):
	def view(self):
	    content= ...
		self.request.htmlmeta.set('title', content.title)
		self.request.htmlmeta.set('description', content.description)

In a template, such as this page.mako example, you can access specific bits of the metadata, or render an entire payload:

<title>${request.htmlmeta.get('title')|n}</title>
${request.htmlmeta.as_html()|n}

Pyramid helpers existed until version 0.3.x but were dropped in favor of the @reify request method offered by the config.include method.

Pylons helpers existed until version 0.1.2 but were dropped.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htmlmeta_hub-0.5.0.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file htmlmeta_hub-0.5.0.tar.gz.

File metadata

  • Download URL: htmlmeta_hub-0.5.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/5.0.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for htmlmeta_hub-0.5.0.tar.gz
Algorithm Hash digest
SHA256 37f7c75f75ddd96d214dba7dcbe2aded84e392be2899af260c9800b5681f2f7d
MD5 1549f5fa7289881912ea244dd7e9635b
BLAKE2b-256 1b757a589eb2292881f4d10132f32b10ea1e8fd7407e44b771766aebb7dcf490

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page