Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FMT function #106

Closed
ziflex opened this issue Oct 12, 2018 · 7 comments
Closed

Add FMT function #106

ziflex opened this issue Oct 12, 2018 · 7 comments
Labels
area/stdlib Standard library issue good first issue Good for newcomers hacktoberfest type/enhancement New feature or request

Comments

@ziflex
Copy link
Member

ziflex commented Oct 12, 2018

Add FMT(template, values) function that would replace placeholders with given values.

Example:

FOR idx IN 1..10
    LET selector = FMT("div.panel-group table tr:nth-child({})", idx)
    RETURN INNER_TEXT(selector)

I think Rust implementation might be more useful for this project, than Go's one.

Especially, ability to reuse parameters using their indexes.

format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2"
@ziflex ziflex added type/enhancement New feature or request good first issue Good for newcomers area/stdlib Standard library issue hacktoberfest labels Oct 12, 2018
@3timeslazy
Copy link
Member

3timeslazy commented Oct 12, 2018

It's possible to reuse parameters by their name using Go's templates. Ex

{{ .P1 }} and {{ .P1 }} and {{ .P2 }}

@ziflex
Copy link
Member Author

ziflex commented Oct 12, 2018

@3timeslazy you are right. Forgot about templates. Have never used them 🤔

@ziflex
Copy link
Member Author

ziflex commented Oct 12, 2018

@3timeslazy do you wanna take this one?

@3timeslazy
Copy link
Member

@ziflex sure.

@3timeslazy
Copy link
Member

As far as I understand, the signature of the FMT function is:

func FMT(tmpl string, args ...core.Value)

@ziflex
Copy link
Member Author

ziflex commented Oct 13, 2018

@3timeslazy yup, looks good!

@ziflex
Copy link
Member Author

ziflex commented Oct 26, 2018

@3timeslazy hey, any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/stdlib Standard library issue good first issue Good for newcomers hacktoberfest type/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants