Skip to content

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