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 join function #204

Merged
merged 5 commits into from
Jun 17, 2021
Merged

add join function #204

merged 5 commits into from
Jun 17, 2021

Conversation

WimLeflere
Copy link
Contributor

Prototype join function (#199), what do you think?

Test and documentation not yet added.

This code

#include <iostream>
#include <vector>

#include <inja/inja.hpp>

int main()
{
   auto data = nlohmann::json();
   data["guests"] = std::vector{ "Jeff","Patrick","Tom" };
   data["numbers"] = std::vector{ 1,2,3 };

   std::cout << inja::render("{{ join(guests, \" - \") }}", data) << '\n';
   std::cout << inja::render("{{ join(numbers, \" | \") }}", data) << '\n';
}

Generates this output

Jeff - Patrick - Tom
1 | 2 | 3

@pantor
Copy link
Owner

pantor commented Jun 17, 2021

Looks good to me! Do you want to add a few tests to test/test-function.cpp?

@WimLeflere WimLeflere marked this pull request as ready for review June 17, 2021 18:47
@pantor pantor merged commit 91c93bf into pantor:master Jun 17, 2021
@pantor
Copy link
Owner

pantor commented Jun 17, 2021

Cool, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants