Skip to content

Instantly share code, notes, and snippets.

@mishak87
Last active August 29, 2015 14:02
Show Gist options
  • Save mishak87/2f4b8afbc406735d184e to your computer and use it in GitHub Desktop.
Save mishak87/2f4b8afbc406735d184e to your computer and use it in GitHub Desktop.
Hyphotetical: Example of generating php code with latte
<?php
/**
* {reusable}
*/
class GenericLogOnEventSubscriber implements Subscriber
{
/**
* {args2prop [ private|public|protected]}
*/
function __construct(Logger $logger, $format);
function getSubscribedEvents()
{
return [ /* {$event} */ => 'eventHandler' ];
}
function eventHandler()
{
$this->logger->log(spritfv($format, func_get_args()))
}
}
@mishak87
Copy link
Author

It could be done by extracting comments and parsing them as templates. If rendered template is empty or only whitespaces removing comment else writing output. Some macros could just set flags etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment