Skip to content

Commit

Permalink
Add Fluent function to Tera, link to data context (#21)
Browse files Browse the repository at this point in the history
* refactor: Reuse tera instance for all types of runs

* deps: Add fluent templating crate as optional dependency

* feat: Inject fluent function to tera

* test: Test use of fluent functions in template

* ci: Add new feature flags to test matrix

* Fix ci

---------

Co-authored-by: Chevdor <chevdor@gmail.com>
  • Loading branch information
alerque and chevdor authored Jun 23, 2023
1 parent 9c3e76d commit 2cc3074
Show file tree
Hide file tree
Showing 10 changed files with 330 additions and 11 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/quick-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
args: --all-features -- -D warnings

quick_check-tests:
strategy:
fail-fast: false
matrix:
feature-flags:
- ''
- '--all-features'
runs-on: ubuntu-latest
steps:
- name: Install Rust stable toolchain
Expand All @@ -67,8 +73,10 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.feature-flags }}

- name: Cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: ${{ matrix.feature-flags }}
250 changes: 248 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ name = "teracli"
readme = "README.md"
version = "0.2.4"

[features]
default = []
fluent = ["fluent-templates"]

[dependencies]
clap = { version = "4", features = ["derive", "env", "unicode", "cargo"] }
env_logger = "0.10"
fluent-templates = { version = "0.8", optional = true, default-features = false, features = ["tera"]}
log = "0.4"
serde = "1.0"
serde_json = { version = "1.0", optional = false }
Expand Down
1 change: 1 addition & 0 deletions data/basic/fluent.tera
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ fluent(key="hello", name=en) }} {{ fluent(key="hello", lang="tr-TR", name=tr) }}
Loading

0 comments on commit 2cc3074

Please sign in to comment.