| Commit message (Collapse) | Author | Age | Lines |
|
|
| |
Fixes #184
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change makes the result of `Group` renderable directly, instead of
panicking, with the important caveat that root-level attributes are
_ignored_. I don't think this will give problems in practice, as the
main use case for rendering `Group` is basically to return root-level
elements to the client using something like HTMX.
I tried adding a `Fragment`, but it was weird and confusing having two
functions (`Group` and `Fragment`) do essentially the same thing, the
only difference being whether the argument was a slice of `Node`s or
varargs.
Fixes #162
|
|
|
|
| |
functions (#194)
|
| |
|
|
|
|
|
|
|
| |
It can appear in a `<blockquote>`.
- Closes https://github.com/maragudk/gomponents/issues/189
Signed-off-by: Yarden Shoham <git@yardenshoham.com>
|
| |
|
| |
|
|
|
|
|
| |
Also add an example for `http.Adapt`.
Fixes #182
|
|
|
|
|
|
| |
For consistency with the other name clashes. Also, adjust the readme.
I know it's a bit weird to add a pre-deprecated function, but know it's
the same as the other functions.
|
| |
|
|
|
|
|
| |
`<time>`, `<del>` and `<ins>` can receive a
[`datetime`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTimeElement/dateTime)
attribute
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I ran into some situation where I want to conditionally render a node if
some variable is not nil and obviously I got a panic
```go
// package viewmodels
type SomePage struct {
s *string
}
// package views
func SomePage (vm viewmodels.SomePage) g,Node {
return Div(
If(vm.s == nil, Text("s is nil"),
If(vm.s !- nil, Text("s is " + vm.s), // this will panic when `s` is nil
)
}
```
In this situation, go will interpret the code of the second `if`
regardless of the condition because the code itself is not in a
condition.
This PR introduces a new `Iff` helper that accepts a callback. The
callback content is only interpreted when it's called, making the code
safe:
```go
// package viewmodels
type SomePage struct {
s *string
}
// package views
func SomePage (vm viewmodels.SomePage) g,Node {
return Div(
Iff(vm.s == nil, func () g.Node { return Text("s is nil") },
Iff(vm.s !- nil, func () g.Node { return Text("s is " + vm.s) },
)
}
```
I'm aware of the `Lazy` effort on the side, but I guess this is no a
breaking change and can still exist in addition to the `Lazy` effort.
Co-authored-by: Markus Wüstenberg <markus@maragu.dk>
|
|
|
|
|
|
|
| |
`dir` is a global attribute that lets you specify whether text is RTL or
LTR or if it should be determined by the browser.
Documentation:
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir
|
|
|
| |
Fixes #168 and fixes #169.
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This change addresses #170 by deprecating some HTML helpers in favor of
using one of the styles as a main one, selected based on what I think is
the main use case.
- For `Data`, it's the attribute. I don't see much use of the `<data>`
element in the wild.
- For `Style`, it's the attribute. The `style` attribute is everywhere,
the `<style>` element is perhaps less so (but not much). This was the
hardest one to decide.
- For `Title`, it's the attribute. The `<title>` element only shows up
once per document.
- For `Form`, it's the element. I haven't seen much use of the `form`
attribute in the wild.
I know this is arguably not a "consistent" approach, but I think it
makes for a much nicer API, simply because the most-used option will not
be a suffixed version.
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
| |
This change addresses #170 by deprecating some HTML helpers in favor of using one of the styles as a main one,
selected based on what I think is the main use case.
- For `Data`, it's the attribute. I don't see much use of the `<data>` element in the wild.
- For `Style`, it's the attribute. The `style` attribute is everywhere, the `<style>` element is perhaps less so (but not much). This was the hardest one to decide.
- For `Title`, it's the attribute. The `<title>` element only shows up once per document.
- For `Form`, it's the element. I haven't seen much use of the `data` attribute in the wild.
I know this is arguably not a "consistent" approach, but I think it makes for a much nicer API, simply because the most-used option will not be a suffixed version.
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When using `<script>` to pull a library from a CDN, it's usually a good
idea to attach an integrity check so that if they get hacked and someone
changes all the script, malicious scripts don't get executed on your
website.
To achieve this, you need to attach `integrity` and `crossorigin` to
your `<script/>` tag
```go
Script(
Scr("https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"),
Integrity("sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"),
CrossOrigin("anonymous"),
)
```
Turns into
```html
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
crossorigin="anonymous"></script>
```
Hint for whoever likes unpkg.com, adding `?meta` at the end of any
script you import form them will give you the current `integrity` for
the file. Example: https://unpkg.com/three@0.165.0/build/three.cjs?meta
|
|/ |
|
|
|
|
| |
This reverts commit b33f84310916b238af0006fb151a4b980721bc33.
|
| |
|
| |
|
|\
| |
| |
| | |
We don't need coverage for the example code and internal testing
helpers.
|
|/
|
|
| |
We don't need coverage for the example code and internal testing helpers.
|
|\ |
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
|\ |
|
|/ |
|
|\
| |
| | |
Fixes #127.
|
|/
|
|
| |
Fixes #127.
|
|\
| |
| |
| |
| | |
Both in the readme and package doc.
Fixes #133.
|
|/
|
|
|
|
| |
Both in the readme and package doc.
Fixes #133.
|
|\
| |
| | |
Fixes #129.
|
| | |
|
|/ |
|
|
|
|
|
| |
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#step
Fixes #120.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
I'd rather reserve the package for components that have proven
repeatedly useful, like `Classes` and `HTML5`.
|
|
|
| |
Like `Raw`, but interpolates like `Textf`.
|
|
|
| |
Also fix godoc badge to point to pkg.go.dev.
|
| |
|