Comments (15)
If this is supported, I'm inclined to do it with python's f-string syntax: f'some string with{{interpolation}}'
from just.
I'm working around this using replace:
value := env_var('VALUE')
result := replace('here is _, _ a pair of values', '_', value)
It's acceptable if you're only using one value multiple times like I am; it would get gnarly with multiple values and replacements.
from just.
This does introduce the odd scenario where you can have interpolation inside a string inside an interpolation inside a string, etc, etc, etc.
from just.
Closing. If anyone wants this, comment and I'll reopen it!
from just.
Maybe thinking that we should do this. Reopening.
from just.
Interesting how nobody has taken this on yet! I am quite interested in having this and have some basic experience working w/ lexers/parsers for other things, so maybe I'll try to take a look soon-ish and see if I can help make this happen!
from just.
I started working on this, in-progress branch here.
I marked this as "good first issue", but I think that's misleading, because it's super hard!
I've gotten lexing and parsing mostly working, but I haven't done evaluation, i.e. actually evaluating the fragments, concatenating them, and, in the case of format backticks, evaluating the result.
If your interested, you could pick up the branch as a starting point. I'm not sure when I'm going to work on it again.
from just.
Is there any news on the subject?
edit: without this I'm forced to go back to make 😅
from just.
Is there any news on the subject?
This is a big feature, so time to implementation is unknown.
from just.
Could this crate be any helpful ?
MiniJinja -- Powerful but minimal dependency template engine for Rust
Announcement on r/rust (2021-09-24).
MiniJinja is a powerful but minimal dependency template engine for Rust which is based on the syntax and behavior of the Jinja2 template engine for Python.
It's implemented on top of serde and only has it as a single dependency. It supports a range of features from Jinja2 including inheritance, filters and more. The goal is that it should be possible to use some templates in Rust programs without the fear of pulling in complex dependencies for a small problem. Additionally it tries not to re-invent something but stay in line with prior art to leverage an already existing ecosystem of editor integrations.
Cheers
from just.
Could this crate be any helpful ?
MiniJinja -- Powerful but minimal dependency template engine for Rust
The template language isn't so much the hard part, it's the rest of the integration, so a crate wouldn't be a huge help.
from just.
For those who might be interested, I developed a simple task system based on the Ruby language.
I needed something effective, pretty simple to use and quick to develop for a project. It already proved itself to be quite powerful : https://github.com/pyrsmk/run
from just.
Is a format expression an easier compromise? I can live without interpolation if there's a string.format(str, args*) method available.
foo := "github.com"
api_uri := "api/v2"
foo_url := string_format("https://%s/%s", foo, api_uri)
from just.
i'm hoping for this addition.
from just.
I'm also interested in this kind of functionality (edit: I'm interested in substitution in backticks in particular), but actually I don't care that this is provided using backticks: for my current use case, a function could be fine as well. Would something like an eval(string)
function be simpler to implement? In that way, we could compose strings and use variables inside expressions:
world := "World!"
greet arg=world:
echo "Hello {{ eval("echo " + arg) }}"
I took a quick look at the code and if the implementation is performed trivially, one could implement a new eval
function that basically replicates what is being done in run_backtick
, although it seems that there is no access to Settings
from the FunctionContext
(and I didn't investigate if that's something that belongs in there).
Edit 2:
I would also consider functions to substitute in strings. I think it's a simpler approach that would provide the feature in backward-compatible way and does not rely on the parser.
from just.
Related Issues (20)
- Add a function to call `just` executable that preserves all CLI-passed parameters HOT 4
- Consider adding just to the Rust Tools APT repo? HOT 2
- `just --fmt`: includes are injected instead of formatted
- Add a way to set the shell per recipe HOT 2
- feat: Include directive with prefixing HOT 2
- Why is `{{args}}` cannot be forwarded quoted? HOT 1
- Unknown attribute `confirm` HOT 1
- Feature Request: Recipe grouping
- Bug: Import statement fails HOT 1
- SIGHUP seems to not be propagated to inner child processes HOT 1
- wishlist: A way to know the recipes target HOT 4
- import and recipes order HOT 1
- Optional modules HOT 4
- Fetch module source files using Git or HTTP HOT 7
- Can't use variadic parameters and parameters prefixed with `&` in same recipe HOT 1
- completions and modules don't work together HOT 7
- [Bug] Executing recipes from imported justfile is done in working dir of imported file HOT 5
- Include completion files in GitHub release artifacts HOT 3
- Feature request: include a descriptive paragraph when listing the behaviour of a Justfile HOT 3
- Feature request: functions to get XDG base directories (home, config, etc)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from just.