gomponentsconverter

package module
v0.0.0-...-e6f3d78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2025 License: MIT Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

About

This tool converts from plain HTML to Gomponents (https://github.com/maragudk/gomponents), a great Go library for generating static HTML in a more type-safe way than the default html/templates. It's usable as both a server (with an HTML or an API, if you so choose) and as a CLI.

A hosted version can be found at https://gomponents.morehart.dev.

Install locally

go install github.com/traherom/gomponentsconverter/cmd/gomponentsconverter@latest

Server

gomponentsconverter serve --port=3333

CLI usage

echo '<div>ioj</div>' | gomponentsconverter convert

Documentation

Overview

Copyright © 2025 Ryan Morehart

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var ErrNothingFound = errors.New("nothing found to convert")

Functions

func BuildRoutes

func BuildRoutes(ctx context.Context) chi.Router

func Convert

func Convert(r io.Reader) (string, error)

func ConvertConfig

func ConvertConfig(config Config, r io.Reader) (string, error)

func ConvertHandler

func ConvertHandler() http.HandlerFunc

func ConvertString

func ConvertString(s string) (string, error)

func IndexHandler

func IndexHandler(ctx context.Context) http.HandlerFunc

func Run

func Run(ctx context.Context, w io.Writer) error

func Serve

func Serve(ctx context.Context, port int) error

Types

type CLI

type CLI struct {
	Serve   ServeCmd   `cmd:"" help:"Run converter as a server"`
	Convert ConvertCmd `cmd:"" default:"" help:"Convert stdin to stdout"`
}

type Config

type Config struct {
	// Should whitespace in the original HTML be preserved in the output?
	PreserveWhitespace bool
	// Prefix calls to helpers functions from gomponents/html
	// Period should be included, ie "g."
	PrefixHTML string
	// Prefix calls to the core Gomponents functions (El, Attr, Text)
	// Period should be included, ie "gomponents."
	PrefixCore string
}

type ConvertCmd

type ConvertCmd struct{}

func (*ConvertCmd) Run

func (s *ConvertCmd) Run(ctx context.Context) error

type ServeCmd

type ServeCmd struct {
	Port int `flag:"" name:"port" default:"3333" help:"Port to serve HTTP"`
}

func (*ServeCmd) Run

func (s *ServeCmd) Run(ctx context.Context, cli *CLI) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址