1
0
Commit Graph

15 Commits

Author SHA1 Message Date
Markus Wüstenberg
f387a71230
Add generic Map implementation (#108)
Instead of waiting for a good time to switch the `Map` implementation,
I've decided to just offer two implementations: one for Go versions
before 1.18, and one for 1.18 and onwards. This is achieved using build
tags in the source files.

This is obviously a breaking change for consumers of this library that
use Go 1.18 and onwards.

See #88
2022-09-22 09:41:06 +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
e6538392ad
Add more complex example using TailwindCSS (#71) 2021-05-07 14:12:23 +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
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
44b18894ac
Add example with dot imports (#47) 2020-11-17 14:50:42 +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
13701c4f66
Add attribute helpers (#35)
Also refactor tests to be table-driven, for readability.
2020-10-28 16:59:04 +01: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
c832941edb
Add simple example (#13) 2020-09-21 16:30:29 +02:00