1
0
Commit Graph

70 Commits

Author SHA1 Message Date
Markus Wüstenberg
aca5cdfe9d Add Github action status badge to readme 2021-06-18 10:10:55 +02:00
Markus Wüstenberg
1ed5851e03 Add contributors file 2021-06-18 10:09:00 +02:00
Markus Wüstenberg
ec86ca5c71
Add video element and related attributes (#84)
Adds the `video` element and `loop`, `muted`, `playsinline`, `poster` attributes.
2021-06-18 09:39:47 +02:00
Markus Wüstenberg
0efc71d6f3
Add javascript alert onclick handler to Raw example (#82)
Makes for fun XSS testing.
2021-06-09 10:56:22 +02:00
Markus Wüstenberg
ba0d83f4fb
Add examples in test files (#80)
These show up in godoc.
2021-06-08 18:12:04 +02:00
Markus Wüstenberg
7c0f2e4cbb
Add LinkStylesheet and LinkPreload components (#79)
These are often used in the `<head>` part of the HTML.
2021-06-08 16:52:57 +02:00
Markus Wüstenberg
3e9e00ca0d
Escape Attr values (#77)
Because this can be a place of injection if untrusted data is passed, escape all attribute values.

Fixes #74.
2021-05-18 14:21:53 +02:00
Markus Wüstenberg
ac7471aac6
Fix TailwindCSS CDN URL in example (#76)
The CSS style URLs from unpkg.com redirected to a different page, but the first request set a `Content-Type` header of `text/plain`. Using the direct URLs fixes this.

Fixes #75. Thanks to @gedw99 for reporting.
2021-05-11 16:39:04 +02:00
Markus Wüstenberg
1072ec9b70
Update readme with content from website (#73) 2021-05-07 14:40:55 +02:00
Markus Wüstenberg
d34b28be56
Bump Go version to 1.16 in CI (#72) 2021-05-07 14:35:47 +02:00
Markus Wüstenberg
e6538392ad
Add more complex example using TailwindCSS (#71) 2021-05-07 14:12:23 +02:00
Markus Wüstenberg
6f7752c20f
Add svg package and a few helpers (#67)
Introducing SVG, to inline vector graphics in your HTML! 🥳
2021-05-05 12:53:32 +02:00
Markus Wüstenberg
eb1d1f22b4
Fix code in readme (#69)
Broken in #66.
2021-05-05 09:53:19 +02:00
Markus Wüstenberg
6f3eea403a
Update license year (#68) 2021-05-05 09:51:42 +02:00
Markus Wüstenberg
3b7dceab89
Streamline HTML element API (#66)
There were a lot of elements previously, like `Em`, `H1`, and a lot more, that took a string as the first argument previously. This was weird when you wanted to mix elements to output html like `<strong><em>…</em></strong>` or `<h1>Something <em>something</em> something</h1>`. gomponents is not an HTML validator, so I want people to be able to use elements however they please, also without text content.

This also means that all elements now have the same API.
2021-05-05 09:03:16 +02:00
Markus Wüstenberg
5d2f0f1b87
Use g.If in HTML5 helper (#65)
Inlining looks much nicer.
2021-04-28 10:42:49 +02:00
Markus Wüstenberg
c899a050c0
Return Node from all helpers instead of NodeFunc (#62)
This makes it clearer that the helpers return a `Node` of any kind, and that the type is not important.

This also streamlines the API, as attribute helpers already return just `Node`.
2021-01-07 10:20:03 +01:00
Markus Wüstenberg
d41c4e5a85
Add data- attribute helper (#61)
Fixes #49.
2020-12-22 11:46:49 +01:00
Markus Wüstenberg
b4918d5a63
Add test for InputHidden (#60) 2020-12-22 11:12:45 +01:00
Markus Wüstenberg
6efec2175f
Add aria-* and role attributes (#59)
Fixes #50.
2020-12-22 11:07:33 +01:00
Markus Wüstenberg
f22ce3fb68
Add If helper function (#57)
Used to inline conditional nodes.
2020-12-22 10:53:22 +01:00
Markus Wüstenberg
428a2519ea
Change main example to be the dot-import version (#56) 2020-12-10 14:27:10 +01:00
Markus Wüstenberg
febffb600d
Simplify available elements (#55)
`a`, `form`, `img`, `input`, `label`, `option`, `progress`, `select`, and `textarea` are now just regular elements (without helper parameters), because:
- Sometimes the use case doesn't fit (`a` as anchor without href, for example)
- There's no reason these are special among the others, so streamlining them makes sense

Also added new attributes `action`, `alt`, `for`, `method` that I had somehow missed.
2020-12-10 14:20:33 +01:00
Markus Wüstenberg
100ae9e830
Rename Document to Doctype (#54) 2020-12-10 13:13:10 +01:00
Markus Wüstenberg
a76262652b
Move elements and attributes into html package (#52)
This makes it easier to use dot-imports.

Also updated the readme and examples with new usage, and move the `Classes` helper into the `components` package.
2020-12-10 13:00:23 +01:00
Markus Wüstenberg
a7e24c6cdd
Minor refactoring and comment changes (#51) 2020-12-08 21:59:47 +01:00
Markus Wüstenberg
44b18894ac
Add example with dot imports (#47) 2020-11-17 14:50:42 +01:00
Markus Wüstenberg
633b000d91
Add svg element (#46)
Also add `cols` and `rows` attributes.

Fixes #43.
2020-11-16 13:03:54 +01:00
Markus Wüstenberg
108f8d9ba5
Add NodeType which replaces the Placer interface (#45)
The `Placer` interface was a weird interface that tried to abstract away nodes being elements or attributes, but it doesn't really make sense. Now `Nodes` just have a `NodeType`.
2020-11-16 12:58:42 +01:00
Markus Wüstenberg
794c3b26ac
Render correct HTML5 (#44)
Previously, elements of kind void and empty elements generally would be rendered auto-closing (with a final `/` character in the start tag), which is allowed sometimes but arguably wrong. See https://dev.w3.org/html5/spec-LC/syntax.html#end-tags

This created problems with for example `textarea` and `script`, which cannot be auto-closing, or the browser renders it wrong.

Also clarified in the docs that this library outputs HTML5.

Fixes #42.
2020-11-16 12:38:24 +01:00
Markus Wüstenberg
87d09c3824
Add package docs (#41)
Also update readme with features.
2020-11-02 11:05:23 +01:00
Markus Wüstenberg
267d40bbea
Add Map function (#40)
`Map` makes it easier to build lists of elements without having to iterate.
2020-11-02 10:59:16 +01:00
Markus Wüstenberg
6c8f0c2352
Render to Writer instead of string (#39)
The Render function has been changed to take a `Writer` instead of returning a string. This makes it possible to generate documents without having the whole content in memory.

This also removes the `gomponents.Write` function, which is now redundant.

Furthermore, the `el.Document` function has been changed to only take one child, as multiple children never make sense for it. (It's not even a child, more a sibling.)
2020-11-02 10:03:05 +01:00
Markus Wüstenberg
92ba5904c1
Remove fmt.Sprintf call in attribute Render (#38)
Just concatenating the strings is much faster.

Before:

```
make benchmark
go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/maragudk/gomponents
BenchmarkAttr/boolean_attributes-8         	 8194791	       139 ns/op
BenchmarkAttr/name-value_attributes-8      	 5143292	       229 ns/op
PASS
ok  	github.com/maragudk/gomponents	2.841s
```

After:

```
make benchmark
go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/maragudk/gomponents
BenchmarkAttr/boolean_attributes-8         	16755404	        67.0 ns/op
BenchmarkAttr/name-value_attributes-8      	10208625	       116 ns/op
PASS
ok  	github.com/maragudk/gomponents	2.702s
```
2020-10-29 15:40:14 +01:00
Markus Wüstenberg
f277d1942e
Pass attributes as pointers (#37) 2020-10-29 13:07:22 +01:00
Markus Wüstenberg
3df42084ae
Add HTML5 document template (#36) 2020-10-29 12:03:43 +01:00
Markus Wüstenberg
13701c4f66
Add attribute helpers (#35)
Also refactor tests to be table-driven, for readability.
2020-10-28 16:59:04 +01:00
Markus Wüstenberg
18e90339fc
Add element helpers and refactor (#34)
This change adds a lot of element helpers, and refactors:
- helpers into simple, text, and other helpers
- most tests into table-driven tests, so they're easier to read

Thanks to @oderwat for pushing me to improve the tests. 😉
2020-10-28 16:16:18 +01:00
Markus Wüstenberg
8f17dba6f1
Add contributing instructions (#33) 2020-10-23 14:32:55 +02:00
Hans Raaf
c6c5fbd0f9
Add br and hr element helpers (#30) 2020-10-23 14:12:47 +02:00
Hans Raaf
c99025e6c5
Remove "fmt" import in readme example (#31)
Also style menu in simple example slightly.
2020-10-23 12:32:47 +02:00
Markus Wüstenberg
3198b25445
Don't render or error on nil children (#32)
This makes it easier to e.g. conditionally skip a component for rendering.
2020-10-23 12:14:23 +02:00
Markus Wüstenberg
6d2fb0eeb1
Add Group function to group Nodes (#29) 2020-10-22 09:07:57 +02:00
Markus Wüstenberg
f2a2b94970
Update package doc for gomponents (#28) 2020-10-21 22:17:27 +02:00
Markus Wüstenberg
42433a4a09
Use HTMLEscapeString in Textf (#27) 2020-10-21 21:59:52 +02:00
Markus Wüstenberg
4448a48d85
Add remaining sectioning elements as helpers (#25)
Fixes #22.
2020-09-25 17:36:21 +02:00
Markus Wüstenberg
83faa4caa3
Use HTMLEscapeString (#24)
HTMLEscaper is not needed with strings.
2020-09-25 13:39:55 +02:00
Markus Wüstenberg
5d5933899c
Update readme with blog post link (#23) 2020-09-25 12:32:50 +02:00
Markus Wüstenberg
5da578cfdf
Group element helpers in different files (#21)
According to the section at https://developer.mozilla.org/en-US/docs/Web/HTML/Element
2020-09-25 09:57:47 +02:00
Markus Wüstenberg
77b64b1302
Add space before auto-closing element (#20) 2020-09-24 21:55:11 +02:00