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

Wrapped after rendering will be lost #8

Closed
inhere opened this issue Mar 27, 2018 · 4 comments
Closed

Wrapped after rendering will be lost #8

inhere opened this issue Mar 27, 2018 · 4 comments
Assignees
Labels

Comments

@inhere
Copy link
Contributor

inhere commented Mar 27, 2018

before:

    public function get(): array
    {
        return ['item0'];
    }

after:

    public function get(): array{
        return ['item0'];
    }

please help fix it. thx

@dermatthes
Copy link
Owner

dermatthes commented Mar 27, 2018

Please attach an example php-file to help me reproduce the error. Maybe we'll need some escaping mechanism...

@inhere
Copy link
Contributor Author

inhere commented Mar 27, 2018

this is a example:

  • some.tpl:
<?php
namespace {= namespace};

/**
 * Class {= className}
 * @Controller(prefix="{= prefix}")
 * @package {= namespace}
 */
class {= className}
{
    /**
     * this is a example action
     * @RequestMapping(route="{= prefix}", method=RequestMethod::GET)
     * @return array
     */
    public function index(): array
    {
        return ['item0', 'item1'];
    }
}
  • use:
$tplFile = 'some.tpl';
$data = [
        'prefix' => '/path',
       'className' => 'DemoController',
       'namespace' => 'App\Controller',
];

$parser = new TextTemplate();
$code = $parser
            ->loadTemplate(\file_get_contents($tplFile))
            ->apply($data);
var_dump($code);
  • the print result:
string(359) "<?php
namespace App\Controller;

/**
 * Class DemoController
 * @Controller(prefix="/path")
 * @package App\Controller
 */
class DemoController
{
    /**
     * this is a example action
     * @RequestMapping(route="/path", method=RequestMethod::GET)
     * @return array
     */
    public function index(): array{
        return ['item0', 'item1'];
    }
}
"

@dermatthes dermatthes self-assigned this Mar 27, 2018
@dermatthes dermatthes added the bug label Mar 27, 2018
@dermatthes dermatthes reopened this Mar 28, 2018
@dermatthes
Copy link
Owner

dermatthes commented Mar 28, 2018

Please verify the last commit fixes this issue for you. (See unit-tests /test/unit/tpls/00_LineBreaks)

@inhere
Copy link
Contributor Author

inhere commented Mar 29, 2018

Yes, thank you very much :)

please publish a new version

@inhere inhere closed this as completed Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants