From 298d733bcaeb4750a2fc74c825be351a91aeed82 Mon Sep 17 00:00:00 2001 From: Stephann Vasconcelos <3025661+stephannv@users.noreply.github.com> Date: Mon, 17 Apr 2023 21:00:43 -0300 Subject: [PATCH 1/2] Add Githut Actions and more examples to README --- .github/workflows/ci.yml | 17 ++++++ .github/workflows/weekly.yml | 30 +++++++++++ .travis.yml | 1 - README.md | 100 ++++++++++++++++++++++++++++++++++- 4 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/weekly.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b218e6f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,17 @@ +name: CI +on: + push: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Download source + uses: actions/checkout@v3 + + - name: Install Crystal + uses: crystal-lang/install-crystal@v1 + + - name: Run tests + run: crystal spec diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml new file mode 100644 index 0000000..45c4bf5 --- /dev/null +++ b/.github/workflows/weekly.yml @@ -0,0 +1,30 @@ +name: Weekly CI +on: + schedule: + - cron: 0 0 * * 1 # At 00:00 on Monday + +jobs: + tests: + strategy: + fail-fast: false + matrix: + include: + - {os: ubuntu-latest, crystal: latest} + - {os: ubuntu-latest, crystal: nightly} + - {os: macos-latest} + - {os: windows-latest} + + name: Tests + runs-on: ${{matrix.os}} + steps: + - name: Download source + uses: actions/checkout@v3 + + - name: Install Crystal + uses: crystal-lang/install-crystal@v1 + with: + crystal: ${{matrix.crystal}} + shards: false + + - name: Run tests + run: crystal spec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ffc7b6a..0000000 --- a/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: crystal diff --git a/README.md b/README.md index 3e6cfda..6fcba12 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ dependencies: ## Usage - +#### Basic usage ```crystal require "html_builder" @@ -25,9 +25,105 @@ html = HTML.build do end end -puts html # => %(crystal is awesome) +puts html +``` + +**Output** (this output is formatted for better display): +```html + + crystal is awesome + +``` + + +#### Full HTML5 page +```crystal +html = HTML.build do + doctype + html(lang: "pt-BR") do + head do + title { text "Crystal Programming Language" } + + meta(charset: "UTF-8") + end + body do + a(href: "http://crystal-lang.org") { text "Crystal rocks!" } + form(method: "POST") do + input(name: "name") + end + end + end +end + +puts html +``` + +**Output** : +```html + + + + + Crystal Programming Language + + + + + + Crystal rocks! +
+ +
+ + +``` + +#### Custom tags + +```crystal +html = HTML.build do + tag("v-button", to: "home") { text "Home" } +end + +puts html ``` +**Output**: +```html + + Home + +``` + +#### Safety + +HTML::Builder escapes attribute values: +```crystal +html = HTML.build do + a(href: "<>") { } +end + +puts html +``` + +**Output**: +```html + +``` + +And escapes text: +```crystal +html = HTML.build do + a { text "<>" } +end + +puts html +``` + +**Output**: +```html +<> +``` ## Contributing 1. Fork it ( https://github.com/crystal-lang/html_builder/fork ) From b5405e21cdaa4f119bf21dfc352281fe5a9f676f Mon Sep 17 00:00:00 2001 From: Stephann V <3025661+stephannv@users.noreply.github.com> Date: Tue, 18 Apr 2023 08:47:22 -0300 Subject: [PATCH 2/2] Add `on: :pull_request` to CI workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Johannes Müller --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b218e6f..8211741 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ name: CI on: push: + pull_request: jobs: test: