#SimpleTemplate, 23 bytes
SimpleTemplate, 23 bytes
This answer is for a language I wrote, which was supposed to be for templates but hasn't seen many updates.
This is the basic "split, loop, output twice", but without the splitting.
{@eachargv.0}{@echo_,_}
And now, ungolfed:
{@each argv.0 as char}
{@echo char, char}
{@/}
And an explanation:
{@each argv.0 as char}
Loops over each value inargv.0
, which is the first argument given when calling therender()
method.
Due to this, you can pass an array of characters or a simple string, and it will loop through it.
Theas char
is optional and the default variable name is_
.
Whitespace is optional{@echo char, char}
Outputschar
. Twice.
Whitespace is optional{@/}
Closes the scope of the{@each ... }
.
This is optional, as the language was written to keep track of how many scopes were open and automatically closes all at the end.
Pretty simple, right?
You can try it on: http://sandbox.onlinephpfunctions.com/code/d008a116a051df131edf02533182c5305cf8e834
When trying, you can go to line 906 and change the variable between $golfed
and $ungolfed
to try both versions.