Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/goradd/html5tag

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/goradd/html5tag

  • v1.0.3
  • Source
  • Go
  • Socket score

Version published
Created
Source

Go Reference Build Status Go Report Card codecov

html5tag

The html5tag package contains utilities to generate html 5 tags. Choose between string versions of the functions for easy tag creation, or io.Writer versions for speed.

html5tag also has a tag builder for convenience and can perform math operations on numeric style values.

html5tag does some checks to make sure tags are well-formed. For example, when adding data-* attributes, it will make sure the key used for the attribute does not violate html syntax rules.

html5tag has options to pretty-print tags and the content of tags so they appear formatted in a document. However, in certain contexts, like in inline text, or in a textarea tag, adding extra returns and spaces changes the look of the output. In these situations, use the functions that do not add spaces to the inner HTML of a tag.

Some examples:

package main

import . "github.com/goradd/html5tag"

main() {
	
	// Render an input tag, inside a div tag, inside a body tag using different tag building mechanisms

	a := NewAttributes().
	SetID("myText").
	Set("text", "Hi there").
	Set("placeholder", "Write here").
	SetClass("class1 class2").
	SetStyle("width":"20em")
	
	inputTag := RenderVoidTag("input", a)
	divTag := RenderTag("div", Attriubtes{"id":"inputWrapper"}, inputTag)
	
	bodyTag := NewTagBuilder().
		Tag("body").
		ID("bodyId").
		InnerHtml(divTag).
		String()
	
	fmt.Print(bodyTag)
}

For complete documentation, start at the documentation for RenderTag() and WriteTag() and drill down from there.

FAQs

Package last updated on 10 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc