Commit Graph

86 Commits

Author SHA1 Message Date
Michael Pfaff 19559e5c09 Allow any ASCII whitespace instead of just space after `<%` 2024-03-15 18:47:29 -04:00
Michael Pfaff 6e09ca7464 Refactor to support custom escaping schemes 2024-03-15 18:05:31 -04:00
Michael Pfaff 2db5b83461 Improve comment syntax 2024-03-11 22:42:08 -04:00
Michael Pfaff 878a026851 Ignore escaping on derived templates 2024-03-11 18:43:13 -04:00
Michael Pfaff 4e2232f2de Unify Render* and Template* traits 2024-03-11 17:33:11 -04:00
Michael Pfaff e5a471d9ca Improve API 2024-03-11 16:57:52 -04:00
Lev af91dc5243 remove space 2023-10-21 14:10:31 -07:00
Lev 4c554d1a57 Fix filename conflict 2023-10-21 14:09:00 -07:00
Newton Ni 01ba06707b Use timestamps for change detection
This commit changes the caching mechanism to use the timestamp of
all included templates instead of hashing the contents of the
root template.

The primary downside is that every build now has to parse, transform,
and resolve the input templates instead of just reading and hashing
the data--I didn't measure how much more expensive this is, but it
seems unavoidable if we need information about child templates.
Maybe a hacky regex-based approach could work as an alternative to
a complete parse.

On the bright side, this approach rebuilds parent templates correctly
when a child template has changed, and doesn't require garbage collection
for old compiled template files.
2023-10-02 13:21:29 -05:00
vthg2themax c05154271a Update config.rs and procmacro.rs 2023-07-28 10:28:02 -04:00
liushuyu 2a8e1a7b7d
dep: update syn to v2 (#115)
* dep: update syn to v2

* fix a broken test.

---------

Co-authored-by: Vince Pike <25014503+vthg2themax@users.noreply.github.com>
2023-04-12 10:02:05 -04:00
Kogia-sima 5fe0934aba Add comment about `include_bytes_seq`
`include_bytes_seq` statements are required for cargo to watch child
templates. Without them, compiler won't re-run after the child templates
are updated.

cc #112
2023-03-05 18:08:56 +09:00
Daniel Arbuckle 96d4ad3e01 switched introductory symbol to + 2023-01-24 07:58:40 -08:00
Daniel Arbuckle c282daf907 Shorthand syntax for rendering a TemplateOnce within another template 2023-01-19 03:07:43 -08:00
Tom 6172cd0dcc Change config file format from YAML to TOML and add support for embedding environment variables in the config file 2021-05-01 06:39:38 +02:00
Kogia-sima 9bf4090468 Better error reporting for missing semicolon in code clock
cc #33 #53
2021-04-06 21:50:20 +09:00
Kogia-sima c9e6449292 Add analyzer.rs
cc #53
2021-02-04 03:11:17 +09:00
Kogia-sima 10ab29be85 Prefer using scope guard for `fallback::unforce()`
This scope guard ensure that `fallback::unforce()` will be called even
if the program panics during compilation.
2021-02-03 15:52:14 +09:00
Kogia-sima 5e12280df1 Fix stable/nightly mismatch error cause by proc-macro2
fix #50
2021-02-03 02:56:15 +09:00
Kogia-sima 7bab7ac0a5 fix: Workaround for incorrect cargo fingerprints
Note: This is a silly hack to prevent temporary artifacts to be tracked
by cargo. This behaviour depends on cargo's internal implementation, and
thus this workaround may suddenly stop working in the future. Another
better option should be considered.
2021-01-23 19:09:54 +09:00
Kogia-sima e69d36b168 refactor: clippy fix 2020-12-29 16:53:46 +09:00
Kogia-sima d07afad79b test: temporarily disable translator test
Currently the translator test cause unexpected error with "-Zprofile"
flag for unknown reason.
2020-12-29 03:24:59 +09:00
Kogia-sima 92c8f8a852 refactor: remove unused code 2020-12-24 17:41:51 +09:00
Kogia-sima 348a3825f2 perf: join after loop-optimization 2020-12-24 17:22:11 +09:00
Kogia-sima 28b5c6abd1 Generate more readable code 2020-12-19 20:51:01 +09:00
Kogia-sima 70033d604d break: forbit implementing TemplateOnce trait by hand 2020-12-19 17:38:57 +09:00
Kogia-sima 15f397348a refactor: Organize source code for readability 2020-12-18 23:00:40 +09:00
Kogia-sima f98ed7426f clippy fix 2020-12-18 19:23:20 +09:00
Kogia-sima 47c09e4f55 refactor: Remove dbg!() 2020-12-18 11:03:44 +09:00
Kogia-sima e221a9b8b9 fix: Fix rendering issue on continue/break statements
fix #21
2020-12-17 13:28:40 +09:00
Kogia-sima a1abc2aaa3 refactor: Simplify derive option parsing 2020-12-16 19:55:28 +09:00
Kogia-sima 98edecdb3a refactor: suppress use of to_string_lossy 2020-12-16 19:13:37 +09:00
Kogia-sima 6c7a74823f refactor: use DefaultHasher instead of custom fnv hash implementation 2020-12-16 19:01:28 +09:00
Kogia-sima 790f7366cf break: Update TemplateOnce trait structure
* Remove render_once_to_string method
* Add render_once_to method
* Now TemplateOnce trait requires both method implementation
* Some performance improvement
2020-12-16 19:01:28 +09:00
Kogia-sima a965f03321 Update error format 2020-12-16 15:38:28 +09:00
Kogia-sima db7aaf5edc Add forbid(unsafe_code) in sailfish-compiler/macros 2020-11-29 21:22:31 +09:00
Kogia-sima 4e949848d0
Merge pull request #34 from Svenskunganka/master
Use std::result::Result in derive macro to allow custom Result types
2020-11-22 11:33:53 +09:00
Kogia-sima 834289be59 refactor: Reduce unsafe blocks 2020-11-21 18:44:52 +09:00
Tom Jordell 9d405ad9ff Use std::result::Result in derive macro to allow custom Result types 2020-11-21 08:40:46 +01:00
Kogia-sima 5666f92b9d Search rustfmt along all toolchains 2020-08-04 03:33:49 +09:00
Kogia-sima 4f64a3b7fe Avoid over-size allocation in `render_once_to_string` 2020-07-25 23:56:17 +09:00
Kogia-sima 4fc278ecfb Revert "Improve Template::render() performance"
This reverts commit 4e8b437387.
2020-07-25 07:48:00 +09:00
Kogia-sima 4e8b437387 Improve Template::render() performance 2020-07-23 11:48:19 +09:00
Kogia-sima cc10171b73 Avoid dangerous conversion from String to Buffer 2020-07-22 07:05:15 +09:00
Kogia-sima 1141580878 Fix number of skips on parsing code block 2020-07-15 23:22:10 +09:00
Kogia-sima 80b64fe883 break: Remove Buffer::set_len method
This method allows reducing the buffer size, but it should not be
possible.
Alternatively I added a Buffer::advance method to increase the length.
2020-07-15 19:49:35 +09:00
Kogia-sima 373ffc135e Implement filter transformation 2020-07-15 07:38:11 +09:00
Kogia-sima 2d15165406 break: Syntactically disallow invalid filter expression 2020-07-15 04:17:50 +09:00
Kogia-sima 119e282945 Avoid generating _size_hint local variable 2020-07-15 00:06:01 +09:00
Kogia-sima 670d936def break: remove runtime::Context API 2020-07-15 00:06:01 +09:00
Kogia-sima 869c58dcb1 Use UFCS instead of receiver coecions
This change is required to achieve filter
2020-07-15 00:06:01 +09:00
Kogia-sima 3040084ca9 do not use `sfrt` as an alias to sailfish::runtime 2020-07-15 00:05:56 +09:00
Kogia-sima 6c72bb17d1 Put all tests in sailfish-tests/ directory 2020-07-14 22:46:58 +09:00
Kogia-sima b420cc0161 feat: Implement Compiler::compile_str() function 2020-07-14 22:07:35 +09:00
Kogia-sima 65636d2ebc Suppress "Failed to remote artifact" error in rust-analyzer 2020-07-13 01:28:42 +09:00
Kogia-sima 9982ab0683 Suppress warning when `config` feature flag is disabled 2020-07-11 17:02:31 +09:00
Kogia-sima f40926122b feat: Add TemplateOnce::render_once_to_string method 2020-06-18 18:37:39 +09:00
Kogia-sima d1b6d2559a feat: New feature flag (config) 2020-06-15 06:44:49 +09:00
Kogia-sima 2d994be4ff feat: Global configuration file 2020-06-15 05:36:39 +09:00
Kogia-sima 25364a6bcc Enhanced error message 2020-06-14 17:30:36 +09:00
Kogia-sima 98e11b1163 fix: Re-compile when child template is update. 2020-06-13 22:58:57 +09:00
Kogia-sima 8a83c2e278 Avoid method name collision in render* macros
fix #9
2020-06-13 13:16:39 +09:00
Kogia-sima 6ac39eee4c refactor: refactor resolver code 2020-06-11 21:35:14 +09:00
Kogia-sima d7a2ff8008 Fix include! implementation for Rust file
Also add tests for including Rust file
2020-06-11 19:43:01 +09:00
Kogia-sima d302f30144 Format code 2020-06-11 19:42:22 +09:00
Kogia-sima dc4d062b8d Test for Error::kind() 2020-06-11 19:22:19 +09:00
Kogia-sima 7665690982 Change input/output directory for integration-tests 2020-06-11 15:31:55 +09:00
Kogia-sima c86effe90f Remove unused function 2020-06-08 22:34:59 +09:00
Kogia-sima 0162e44ff8 Remove unused code 2020-06-07 23:23:45 +09:00
Kogia-sima eeeb47ed84 Remove #[allow(dead_code)] for function 2020-06-07 23:20:36 +09:00
Kogia-sima 5c7065a411 Use proc_macro2::fallback::force() API
This api forces the use of proc-macro2's fallback implementation. This
allows to keep span information during parsing.
2020-06-07 20:52:38 +09:00
Kogia-sima fd3d224067 Refactor source code with rustfmt and clippy
[skip ci]
2020-06-07 17:58:52 +09:00
Kogia-sima 61ff466976 Add `rm_whitespace` option 2020-06-07 13:00:28 +09:00
Kogia-sima 9c4b6352d5 Add rm_whitespace option 2020-06-07 13:00:28 +09:00
Kogia-sima 94e7ce2e8a TODO comments
[skip ci]
2020-06-07 11:49:15 +09:00
Kogia-sima f3c9a21140 Resolve include! for Rust file correctly 2020-06-07 04:53:49 +09:00
Kogia-sima b24861e158 Skip attribute if it is not wrapped with `template` 2020-06-07 03:44:30 +09:00
Kogia-sima 76abe1c0ac Pop include path stack 2020-06-07 03:21:17 +09:00
Kogia-sima e7c0992568 Export compiler config struct 2020-06-07 03:20:01 +09:00
Kogia-sima 6d07c43876 Strip the brake line at end of file 2020-06-07 01:25:52 +09:00
Kogia-sima 8e5b76f2ab Ignore include! for rust file 2020-06-07 00:52:53 +09:00
Kogia-sima 7d77b755c6 Resolve child template path inside resolver 2020-06-07 00:43:10 +09:00
Kogia-sima 64ded9616a resolve to relative path in include! by default 2020-06-06 23:43:41 +09:00
Kogia-sima 12174ff5c5 Implement include! macro 2020-06-06 22:49:01 +09:00
Kogia-sima 420d83521c Add Config struct 2020-06-06 11:58:14 +09:00
Kogia-sima 08dacdd263 Add source code 2020-06-05 22:31:38 +09:00