Skip to main content
Commonmark migration
Source Link

#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 in argv.0, which is the first argument given when calling the render() method.
    Due to this, you can pass an array of characters or a simple string, and it will loop through it.
    The as char is optional and the default variable name is _.
    Whitespace is optional

  • {@echo char, char}
    Outputs char. 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.

#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 in argv.0, which is the first argument given when calling the render() method.
    Due to this, you can pass an array of characters or a simple string, and it will loop through it.
    The as char is optional and the default variable name is _.
    Whitespace is optional

  • {@echo char, char}
    Outputs char. 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.

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 in argv.0, which is the first argument given when calling the render() method.
    Due to this, you can pass an array of characters or a simple string, and it will loop through it.
    The as char is optional and the default variable name is _.
    Whitespace is optional

  • {@echo char, char}
    Outputs char. 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.

Formatting and fixed spelling mistake
Source Link
Ismael Miguel
  • 7.9k
  • 2
  • 25
  • 38

#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 in argv.0, which is the first argument given when calling the render() method.
    Due to this, you can pass an array of characters or a simple string, and it will loop through it.
    The as char is optional and the default variable name is _. 
    Whitespace is optionalWhitespace is optional

  • {@echo char, char}
    Outputs char. Twice. 
    Whitespace is optionalWhitespace is optional

  • {@/}
    Closes the scope of the {@each ... }. 
    This is optionalThis is optional, as the language was written to keep trachtrack 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.

#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 in argv.0, which is the first argument given when calling the render() method.
    Due to this, you can pass an array of characters or a simple string, and it will loop through it.
    The as char is optional and the default variable name is _. Whitespace is optional

  • {@echo char, char}
    Outputs char. Twice. Whitespace is optional

  • {@/}
    Closes the scope of the {@each ... }. This is optional, as the language was written to keep trach 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.

#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 in argv.0, which is the first argument given when calling the render() method.
    Due to this, you can pass an array of characters or a simple string, and it will loop through it.
    The as char is optional and the default variable name is _. 
    Whitespace is optional

  • {@echo char, char}
    Outputs char. 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.

Source Link
Ismael Miguel
  • 7.9k
  • 2
  • 25
  • 38

#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 in argv.0, which is the first argument given when calling the render() method.
    Due to this, you can pass an array of characters or a simple string, and it will loop through it.
    The as char is optional and the default variable name is _. Whitespace is optional

  • {@echo char, char}
    Outputs char. Twice. Whitespace is optional

  • {@/}
    Closes the scope of the {@each ... }. This is optional, as the language was written to keep trach 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.