Skip to content

Commit

Permalink
release: Prepare 0.8.0 release (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv authored Sep 14, 2024
1 parent f2f1fe5 commit c9e86bf
Show file tree
Hide file tree
Showing 3 changed files with 283 additions and 26 deletions.
305 changes: 281 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,138 @@

All notable changes to this project will be documented on <https://stephannv.github.io/blueprint-docs/>.

## [0.7.0] - 2023-09-09
# [0.8.0] - 2024-09-14

### Overhauled docs
The [Blueprint Docs](https://stephannv.github.io/blueprint-docs/) was revised.

### Style Variants (Experimental)
Defining a schema for variants within the component class to compile the final list of CSS classes.

```crystal
class AlertComponent
include Blueprint::HTML
style_builder do
base "alert"
variants do
type {
info "alert-info"
danger "alert-danger"
}
size {
xs "text-xs p-2"
md "text-md p-4"
lg "text-lg p-6"
}
closable {
yes "alert-closable"
}
special {
yes "alert-special"
no "alert-default"
}
end
defaults type: :info, size: :md
end
def blueprint
div(class: build_style(type: :danger, size: :lg, closable: true)) do
"My styled alert component"
end
end
end
puts AlertComponent.build_style(type: :info, size: :xs, special: false)
# "alert alert-info text-xs p-2 alert-default"
puts AlertComponent.new.to_s
# <div class="alert alert-danger text-lg p-6 alert-closable">
# My styled alert component
# </div>
```

### Tokens (Experimental)
Allows to build classes based on conditionals.

```crystal
class UserComponent
include Blueprint::HTML
def blueprint
h1 class: tokens(admin?: "is-admin", moderator?: "is-moderator") do
"Jane Doe"
end
end
def admin?
false
end
def moderator?
true
end
end
puts UserComponent.new.to_s
# <h1 class="is-moderator">
# Jane Doe
# </h1>
```

### Add `#safe` helper
The `#safe` method wraps the given object in a `Blueprint::SafeValue`, indicating
to Blueprint that the content should be rendered without escaping.

### BREAKING: Change `#to_html` to `#to_s`
Instead of `MyComponent.new.to_html` you should use `MyComponent.new.to_s`.

### BREAKING: Remove some utils methods
The methods `#plain(&)` and `#comment(&)` were removed, but you still can use
the `#plain(content : String)` and `#comment(content : String)`.

### BREAKING: Remove `#unsafe_raw`
`#unsafe_raw` was removed in favor of `#raw`.
```crystal
# BEFORE
unsafe_raw "<script>My Script</script>"
# AFTER
raw safe("<script>My Script</script>")
```

### BREAKING: Remove `Blueprint::RawHTML`
The `Blueprint::RawHTML` included in 0.7.0 was removed. A module focused on performance will be planned in the future.

### Include Blueprint::HTML::ComponenentRegistrar by default
You don't need to require and include `Blueprint::HTML::ComponenentRegistrar`, it
is already included when you include `Blueprint::HTML`.


# [0.7.0] - 2024-09-09

### Allow passing comment via argument

- Allow passing comment via argument
```crystal
comment "Cool comment here"
```

- Allow rendering unsafe content using `unsafe_raw`
### Allow rendering unsafe content using `unsafe_raw`

```crystal
unsafe_raw "<script>alert('Danger!')</script>"
```

- Add `RawHtml` to priorize performance over safety

### RawHTML

Add `RawHtml` to priorize performance over safety
```crystal
require "blueprint/unsafe_html"
class MyHTML
Expand All @@ -26,11 +145,16 @@ class MyHTML
end
```

- Code refactoring to improve performance
- Fix safety when passing content to elements via argument
### Code refactoring
Code refactoring to improve performance

### Fix escaping
Fix safety when passing content to elements via argument


# [0.6.0] - 2024-09-08

## [0.6.0] - 2023-09-08
### Passing content via argument

Allows passing content to elements without using blocks, eg.

Expand All @@ -40,39 +164,172 @@ Allows passing content to elements without using blocks, eg.
h1 "Hello World!"
```

Release details: <https://stephannv.github.io/blueprint-docs/changelogs/v0.6.0/>
# [0.5.1] - 2024-09-08

## [0.5.1] - 2023-09-08
Fix Crystal version string requirement allowing using Blueprint with newer crystal versions.

Fix Crystal version string requirement.
# [0.5.0] - 2024-09-08

Release details: <https://stephannv.github.io/blueprint-docs/changelogs/v0.5.1/>
### Performance improvements

## [0.5.0] - 2023-09-08
Increased speed execution by 15%.

Performance improvements: Increased speed execution by 15%.
```
v0.5.0 364.46k ( 2.74µs) (± 0.52%) 7.95kB/op fastest
v0.4.0 317.83k ( 3.15µs) (± 0.76%) 8.99kB/op 1.15× slower
```

### Fix Array attributes

Ignore nil elements from array attribute parsing

```crystal
class Example
include Blueprint::HTML
private def blueprint
h1(class: ["a", "b", nil, ["c", "d"]]) { "Example" }
end
end
example = Example.new
example.to_html # => "<h1 class="a b c d">Example</h1>"
```


# [0.4.0] - 2023-04-25

### SVG support

It's possible to create SVG elements:

```crystal
class Example
include Blueprint::HTML
private def blueprint
svg width: 30, height: 10 do
g fill: :red do
rect x: 0, y: 0, width: 10, height: 10
rect x: 20, y: 0, width: 10, height: 10
end
end
end
end
```

Output:
```html
<svg width="30" height="10">
<g fill="red">
<rect x="0" y="0" width="10" height="10"></rect>
<rect x="20" y="0" width="10" height="10"></rect>
</g>
</svg>
```


# [0.3.0] - 2023-04-07

### Build HTML without defining classes or structs

It's possible build HTML without using classes or structs

```crystal
html = Blueprint::HTML.build do
h1 { "Hello" }
div do
h2 { "World" }
end
end
puts html # => <h1>Hello</h1><div><h2>World</h2></div>
```

Release details: <https://stephannv.github.io/blueprint-docs/changelogs/v0.5.0/>

## [0.4.0] - 2023-04-25
# [0.2.0] - 2023-04-07

### Allow conditional rendering

Release details: <https://stephannv.github.io/blueprint-docs/changelogs/v0.4.0/>
It's possible to override `#render?` method to control blueprint render.

## [0.3.0] - 2023-04-07
```crystal
class Example
include Blueprint::HTML
private def blueprint
h1 { "Example" }
end
private def render?
false
end
end
example = Example.new
example.to_html # => ""
```

### Handles array attributes

Arrays passed as attribute values will be flattened and joined with `" "`.

```crystal
class Example
include Blueprint::HTML
private def blueprint
h1(class: ["a", "b", ["c", "d"]]) { "Example" }
end
end
example = Example.new
example.to_html # => "<h1 class="a b c d">Example</h1>"
```

### Adds `#envelope(&)` method

By overriding the `#envelope(&)` method, you can create a wrapper around
blueprint content. This is useful when defining layouts for pages.

```crystal
class Example
include Blueprint::HTML
private def blueprint
h1 { "Example" }
end
private def envelope(&)
html do
body do
yield
end
end
end
end
example = Example.new
example.to_html # => "<html><body><h1>Hello</h1></body></html>"
```

Release details: <https://stephannv.github.io/blueprint-docs/changelogs/v0.3.0/>
### Breaking changes
- Requires `require "blueprint/html"` instead `require "blueprint"` to use `Blueprint::HTML` module

## [0.2.0] - 2023-04-07

Release details: <https://stephannv.github.io/blueprint-docs/changelogs/v0.2.0/>

## [0.1.0] - 2023-03-27
# [0.1.0] - 2023-03-27

Release details: <https://stephannv.github.io/blueprint-docs/changelogs/v0.1.0/>
### Added
- Basic html builder
- Allow element attributes
- Allow rendering blueprints
- Allow NamedTuple attributes
- Add `doctype` util
- Transform attribute names
- Handle boolean attributes
- Escape content
- Add `comment` util
- Add `whitespace` util
- Allow custom component registration
- Allow custom element registration
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: blueprint
description: |
Blueprint is a lib for writing reusable and testable HTML templates in plain Crystal, allowing an OOP (Oriented Object Programming) approach when building your views.
version: 0.7.0
version: 0.8.0

authors:
- Stephann V. <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/blueprint/version.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Blueprint
VERSION = "0.7.0"
VERSION = "0.8.0"
end

0 comments on commit c9e86bf

Please sign in to comment.