Type-safe Go library for creating and manipulating HTML elements (with htmx helpers).
MIT License
Published by chasefleming about 1 year ago
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>
.
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.Style
TypeOptimized 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.
A special shoutout to the contributors who added to this release:
Published by chasefleming about 1 year ago
Link
Element SupportWe'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.
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.
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.
A special shoutout to the contributors who added to this release:
Published by chasefleming about 1 year ago
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.
The attrs
package has been augmented with an expanded set of style properties. This broadens the scope of design possibilities for the users.
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
.
A special shoutout to the contributors who added to this release:
Published by chasefleming about 1 year ago
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.
*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 StringsFor 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..."))
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.
Users can expect:
Published by chasefleming about 1 year ago
π 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!
Published by chasefleming about 1 year ago
We've added new HTML elements to make your Go-based HTML generation even more powerful.
Blockquote
): Create a <blockquote>
element for indicating long quotations in your content.Br
): Easily add line breaks with the <br>
element.Code
): Perfect for inline code snippets, this function generates the <code>
element.Em
): Add emphasis to your text with the <em>
element.Hr
): Create thematic breaks in your content using the <hr>
element.Pre
): Preserve both spaces and line breaks with the <pre>
element, ideal for displaying code blocks.Strong
): Make your text bold and give it strong importance using the <strong>
element.Published by chasefleming about 1 year ago
π Introducing elem-go
: A fresh library for creating HTML components programmatically in Go!
elem-go
, enjoy type safety in defining and manipulating HTML elements, minimizing potential runtime errors and ensuring a smoother development experience.elem-go
encapsulates the complexity behind defining HTML attributes and elements, making your code more readable and maintainable.htmx
Helpers: Craft dynamic web elements effortlessly with the built-in htmx
helpers. No need for verbose attribute strings anymore.examples
directory for hands-on usage of elem-go
. Start with the htmx-counter
demonstration!Div
) to headers (H1
, H2
, β¦) and interactive components.attrs
and styles
subpackages to define element attributes and styles in a type-safe manner confidently.htmx
subpackage provides constants and utility functions tailored for htmx
specific attributes.Show
for conditional rendering of elements.go get github.com/chasefleming/elem-go
examples
directory to see elem-go
in real-world scenarios.