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

[BUG] Partial does not return string, but renders partial automatically #543

Closed
pdeszynski opened this issue Apr 11, 2013 · 10 comments
Closed

Comments

@pdeszynski
Copy link
Contributor

According to this issue #27 and documentation, partial should return rendered string. Instead it returns null and automatically adds it's content to the template without need of print/echo.

@nikolasha
Copy link

This is not a bug, it's a feature that I do not like the ;)

@pdeszynski
Copy link
Contributor Author

According to the documentation for Phalcon\Mvc\View\EngineInterface
https://phalcon-php-framework-documentation.readthedocs.org/en/latest/api/Phalcon_Mvc_View_EngineInterface.html?highlight=partial

abstract public string partial (string $partialPath);

So I'm not sure which to believe :)

@phalcon
Copy link
Collaborator

phalcon commented Apr 11, 2013

Maybe the function prototype is wrong but this function doesn't return a string. If you need to get a view as a string you can use getRender in Phalcon\Mvc\View:

$this->view->getRender('partials', 'my-view', ['someVar' => $value]);

@phalcon phalcon closed this as completed Apr 11, 2013
@ghost
Copy link

ghost commented Sep 20, 2013

Don't like that either, echo $this->partial('thepartialfile', $data) is a very common used feature among other php frameworks

@wojtek77
Copy link

I also need to "$this->partial()" return a string. Should be in the function of the third parameter "$returnAsString = false".

@pdeszynski
Copy link
Contributor Author

@phalcon Is there a chance of getting one more param inside of partial function to return rendered contents as a string?

@phalcon
Copy link
Collaborator

phalcon commented May 16, 2014

@piteer1 I think this is already implemented in 1.3.2

@khoan
Copy link

khoan commented Jan 18, 2015

@phalcon It seems third argument is NOT supported in 1.3.2.

$this->partial('bam/bam', array(), true)

BadMethodCallException: Wrong number of parameters
#0 /path/to/src/app/views/post_treatment/update.js.php(21): Phalcon\Mvc\View\Engine->partial('patient/card', Array, true)
#1 [internal function]: Phalcon\Mvc\View\Engine\Php->render('/Users/khoan/cl...', Array, true)
#2 [internal function]: Phalcon\Mvc\View->_engineRender(Array, 'post_treatment/...', true, true, NULL)
#3 [internal function]: Phalcon\Mvc\View->render('post_treatment', 'update', Array)
#4 /path/to/src/public/index.php(128): Phalcon\Mvc\Application->handle()
#5 {main}

@khoan
Copy link

khoan commented Jan 18, 2015

I think this issue hasn't been merged.
#2140

@khoan
Copy link

khoan commented Jan 18, 2015

this workaround does the job
rianorie@b2fb750

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

No branches or pull requests

4 participants