blurgyy / dt

🏘 $HOME, $HOME everywhere
https://dt.cli.rs
Other
29 stars 0 forks source link

question: ability to disable template rendering #18

Closed CharlesChiuGit closed 1 year ago

CharlesChiuGit commented 1 year ago

Some of my file doesn't comply with Handlebars syntax. Is it possible to add a local setting that can just symlink/copy the file over to target? Or is there other way around?

linux.toml: 圖片

error log: 圖片

lfrc:L34: https://github.com/CharlesChiuGit/dotfiles/blob/077960d9e2c7bc75813fe792964731aeb03874e3/cli-utils/lf/lfrc#L34

blurgyy commented 1 year ago

Hi @CharlesChiuGit,

Thank you for opening an issue!

dt-cli supports this with a config option renderable which defaults to true. To avoid rendering a source file, you can add renderable = false for the group that you want to to skip template rendering, or add the renderable = false line under [global] to disable templating globally. This has been mentioned in the documentation here. E.g.

# this is a config file for dt-cli
[global]
# renderable = false  # globally disables templating

[[local]]
name = "lf"
base = "/some/path"
sources = [ "lfrc", "and", "some", "other", "files" ]
target = "/some/other/path"
# renderable = false  # disables templating only for this group

Another solution (more of a workaround) is to escape the handlebars inside the source file itself by adding a backslash before the opening "handlebar". With this workaround, dt-cli's config file does not need to be modified. E.g.:

-cmd open ${{
+cmd open $\{{
     test -L $f && f=$(readlink -f $f)
     case $(file --mime-type $f -b) in
         text/*) $EDITOR $fx;;
         *) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
     esac
 }}

I recommend you to refer to the Key References section in the documentation while creating a config file for dt-cli, but feel free to let me know if any problem arises.

Cheers!

CharlesChiuGit commented 1 year ago

aha, I didn't notice there's a "Guide" and "Key References" section on the website. Since "Hands-on Guide" covers 90% of my use case, so I didn't bother to find other docs lmao, my bad. (But I also think it's would be a bit better to mention there's a more thorough doc in the "Hands-on Guide" section.

Thanks for your great work and the well-explanation on the "Hands-on Guide" section. (And the website itself is very well built, may I ask if there's any templates that u used or u built it from scratch?

This project deserves more stars.

I'll let u know how thing goes afterwards!

CharlesChiuGit commented 1 year ago

A little reminder, some doc might needs some updates. For example, it's now base rather than basedir, but the "Hands-on Guide" still shows basedir in the examples. image

CharlesChiuGit commented 1 year ago

Adding renderable = false did fix the issue. tks!

blurgyy commented 1 year ago

Thanks for your great work and the well-explanation on the "Hands-on Guide" section.

This project deserves more stars.

Thanks for the kind words, they mean a lot to me!

the website itself is very well built, may I ask if there's any templates that u used or u built it from scratch?

The documentation website is built with VitePress, using a theme modified from Vuejs' blog, you can inspect its sources at the docs branch.

A little reminder, some doc might needs some updates. For example, it's now base rather than basedir, but the "Hands-on Guide" still shows basedir in the examples.

I have now updated the docs, thanks again for the heads up!