elem-go

Type-safe Go library for creating and manipulating HTML elements (with htmx helpers).

MIT License

Stars
311
elem-go - Version 0.8.0

Published by chasefleming about 1 year ago

✨ New Elements Added

Idiomatic Text Element Support

Introduced support for the <i> element. Traditionally, this element is used to represent idiomatic text set off from the normal prose, such as technical terms, foreign language phrases, or thoughts. It's also commonly used for embedding icons, especially with font libraries.

Example for idiomatic text: <i>Example idiomatic phrase</i>.

Table Elements

Introduced a variety of table-related elements to better facilitate the display of tables. The new elements include:

  • <table>: For tabular data.
  • <thead>, <tbody>, and <tfoot>: For grouping header, body, and footer content in a table respectively.
  • <tr>: For table rows.
  • <th> and <td>: To denote header and data cells.

🏎️ Improvements

Performance Enhancement for Style Type

Optimized the String method in the Style type. Instead of using string concatenation, which could lead to multiple memory allocations for styles with numerous properties, we've switched to strings.Builder for enhanced performance.

πŸ™ Thanks to Contributors

A special shoutout to the contributors who added to this release:

  • @u5surf
  • @Khusyasy
  • @lemjoe
elem-go - Version 0.7.0

Published by chasefleming about 1 year ago

✨ New Elements Added

Added Link Element Support

We've introduced support for the <link> HTML element, making it easier for developers to add stylesheet links and other link-based meta information to their HTML head.

Expanded List Elements Support

We've added functions to easily create <dl>, <dt>, <dd>, and <ol> HTML elements. This will help developers structure their lists and definitions in a more semantic and accessible manner.

Introduced Semantic Sectioning Elements

We've added support for the <article>, <aside>, <footer>, <header>, <main>, <nav>, and section HTML elements. These elements will allow developers to structure their content semantically, improving accessibility and search engine optimization.

πŸ™ Thanks to Contributors

A special shoutout to the contributors who added to this release:

  • @chasefleming
  • @lemorage
elem-go - Version 0.6.0

Published by chasefleming about 1 year ago

πŸš€ New Features

HTMX Attributes

Additional htmx attributes have been incorporated to further improve the versatility of the package. This ensures users can fully harness the power of htmx when developing their applications.

Style Properties

The attrs package has been augmented with an expanded set of style properties. This broadens the scope of design possibilities for the users.

⚠️ Breaking Changes

Show Is Now If

The utility function Show has been deprecated and replaced with a more versatile and clearer generic function, If. This change was introduced to provide better semantics and more flexibility. Users who have implemented Show in their code should replace its usage with If.

πŸ™ Thanks to Contributors

A special shoutout to the contributors who added to this release:

  • @chasefleming
  • @Paul-Annay
  • @MhmoudGit
  • @stefan-anevski
  • @anevski-stefan
elem-go - Version 0.5.0

Published by chasefleming about 1 year ago

Enhancements

Improved Type Safety

Replaced the interface{} type for element children with a more specific Node type. The introduction of the Node type aims to reduce ambiguity in the code and ensure type safety, leading to fewer runtime errors. We recommend developers to review their code for direct usages of *Element and refactor them to utilize the Node type.

Breaking Changes

*Element Returns Change to Node

Functions that previously returned *Element should now return Node. If you were using such functions, please update your implementations to handle the new return type.

Affected Function Example:

func renderItems(items []Item) []*elem.Element {
    // rest of code...
}

Becomes:

func renderItems(items []Item) []elem.Node {
    // rest of code code...
}

Text() Required for Strings

For elements like option, textarea, and others that previously accepted strings directly, you now need to use the Text() function.

Previously Allowed Usage:

Textarea(Attrs{attrs.Name: "comment", attrs.Rows: "5"}, "Leave a comment...")

Becomes:

Textarea(Attrs{attrs.Name: "comment", attrs.Rows: "5"}, Text("Leave a comment..."))
elem-go - Version 0.4.0

Published by chasefleming about 1 year ago

In this release, we've made significant optimizations to the rendering process of HTML elements. These changes offer faster and more efficient HTML generation, especially for larger documents.

πŸš€ Improvements

  • Optimized String Operations: Transitioned to a more efficient method of string handling, reducing the overhead associated with generating HTML strings.
  • Streamlined Rendering Process: Introduced enhancements that allow for a more direct and efficient rendering flow, minimizing unnecessary operations.
  • Refined Recursion Mechanics: Made changes to the way nested elements are rendered, further improving performance and memory usage.

Impact

Users can expect:

  • Faster rendering times for their HTML documents.
  • Reduced memory usage during the rendering process.
  • High-quality and consistent HTML generation.
elem-go - Version 0.3.0

Published by chasefleming about 1 year ago

New Features

πŸ†• Form Elements Support

We've introduced first-class support for HTML form elements, enhancing the capability to create forms programmatically with type safety in Go. Here are the latest additions:

  • Form: Generate <form> elements.
  • Input: Create <input> fields, from text to radio buttons, and more.
  • Label: Attach <label> elements to form fields for accessibility.
  • Select: Construct dropdown <select> menus.
  • Textarea: Define multiline <textarea> fields.
  • Option: Populate dropdowns with <option> values.

These new utilities simplify the process of generating HTML in Go. Now, creating anything from a simple contact form to an intricate multi-step wizard is even more straightforward!

elem-go - Version 0.2.0

Published by chasefleming about 1 year ago

We've added new HTML elements to make your Go-based HTML generation even more powerful.

πŸš€ New Additions:

  • Blockquote (Blockquote): Create a <blockquote> element for indicating long quotations in your content.
  • Br (Br): Easily add line breaks with the <br> element.
  • Code (Code): Perfect for inline code snippets, this function generates the <code> element.
  • Em (Em): Add emphasis to your text with the <em> element.
  • Hr (Hr): Create thematic breaks in your content using the <hr> element.
  • Pre (Pre): Preserve both spaces and line breaks with the <pre> element, ideal for displaying code blocks.
  • Strong (Strong): Make your text bold and give it strong importance using the <strong> element.
elem-go - Version 0.1.0

Published by chasefleming about 1 year ago

πŸš€ Introducing elem-go: A fresh library for creating HTML components programmatically in Go!

Highlights:

  • πŸ›  Type-Safe HTML Generation: Leverage the strong typing features of Go. With elem-go, enjoy type safety in defining and manipulating HTML elements, minimizing potential runtime errors and ensuring a smoother development experience.
  • πŸ“¦ Common HTML Elements & Attributes: Simplify your codebase! elem-go encapsulates the complexity behind defining HTML attributes and elements, making your code more readable and maintainable.
  • πŸ’‘ Integrated htmx Helpers: Craft dynamic web elements effortlessly with the built-in htmx helpers. No need for verbose attribute strings anymore.
  • πŸ“– Examples to Kickstart: Dive into the examples directory for hands-on usage of elem-go. Start with the htmx-counter demonstration!

New Features:

  • HTML Elements: Comprehensive support for a wide array of HTML elementsβ€”from basic divisions (Div) to headers (H1, H2, …) and interactive components.
  • Attributes & Styling: Use the attrs and styles subpackages to define element attributes and styles in a type-safe manner confidently.
  • htmx Integration: The new htmx subpackage provides constants and utility functions tailored for htmx specific attributes.
  • Conditional Rendering: Introducing the utility function Show for conditional rendering of elements.

Getting Started:

  1. Install with go get github.com/chasefleming/elem-go
  2. Explore the detailed documentation to understand the full spectrum of features.
  3. Try out the examples directory to see elem-go in real-world scenarios.