-
Notifications
You must be signed in to change notification settings - Fork 3
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
Can reveal/reveal-latte
be used in a project that doesn't use nette/application
?
#11
Can reveal/reveal-latte
be used in a project that doesn't use nette/application
?
#11
Comments
Hi, this is a monorepo, so submitting project issue here is the way 👍 The functionality depends on We use thiese only on Nette application, so you'd have to check those template holders if they match your template usage. |
The way I'm using Latte can basically be boiled down to:
{templateType My\Stuff\CoolTemplate}
<div>{$foo}</div>
<?php declare(strict_types=1);
namespace My\Stuff;
final class CoolTemplate {
public function __construct(
public string $foo,
) {}
}
<?php declare(strict_types=1);
namespace My\Stuff
final class Whatever {
public static function doThing(): string {
$latte = new \Latte\Engine();
$latte->setTempDirectory('/my-temp-folder-path');
return $latte->renderToString(
__DIR__ . '/CoolTemplate.latte',
new CoolTemplate(
foo: 'bar'
)
);
}
} After taking a look at the template holders, it appears that none support this way of doing things. Notably, after changing something (or maybe I just wasn't testing right earlier), PHPStan now fails as long as the |
Could you add this as a test case here!? |
Yeah, I think I can try and submit a PR to do that. One question, though: what's the difference between the stuff in the "Source" folder versus the "Fixture" folder? I don't really understand the organization here. |
The The |
Maybe we should just add |
I've check this and it will not be enough with your use case. You use Latte\Engine::renderToString in way I've never seen and I event didn't know it is possible :) |
@lulco Is the blocker the usage of an object to provide the template arguments? Would chaning (If so, that's pretty ironic, since the point of the @TomasVotruba I've opened #18 to add tests for the " |
For now, yes. We need to implement it.
Probably yes, we need to test it.
You can still use {templateType} in your latte files, it is just for IDE, it is ignored by compiler and also by reveal static analysis.
Thanks, we will check it :) |
In my project, I'm trying to use Latte templates without any of the rest of the Nette libraries; specifically, I'm not using Nette Application at all. I simply render Latte templates via
\Latte\Engine#renderToString
in my own custom classes.I'm using
{templateType}
alongside classes with typed parameter constructors, so hypothetically, it should be possible for a PHPStan extension to find the.latte
files, lookup the matching class, and verify that the parameters line up in number and type.However, after installing
reveal/reveal-latte
and running PHPStan, it doesn't seem to have any effect. Yes, I made sure thatphpstan/extension-installer
was working, and I even manually added all the rules to my PHPStan config like so:EDIT: turns out that since
Reveal\RevealLatte\Rules\LatteCompleteCheckRule
is auto-registered byphpstan/extension-installer
, it should not be registered again in your config - doing so will cause it to crash. See #12.Is my use case supported by
reveal/reveal-latte
? If so, what am I doing wrong; and if not, could the plugin be updated to support my use case? The docs for the plugin aren't really clear on this to me.Side note: should issues and/or PRs for
reveal/reveal-latte
be submitted here or https://github.com/revealphp/reveal-latte?The text was updated successfully, but these errors were encountered: