Skip to content

BC {snippetArea} #240

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

Closed
ikeblaster opened this issue Nov 18, 2020 · 11 comments
Closed

BC {snippetArea} #240

ikeblaster opened this issue Nov 18, 2020 · 11 comments

Comments

@ikeblaster
Copy link

Version: 2.9.0

Bug Description

{snippetArea} without arguments now throws exception Missing arguments in {snippetArea} in file.latte:10

Steps To Reproduce

Compile latte template with following:

{snippetArea}
    ...
{/snippetArea}

Possible Solution

$node->validate(true);

Change to:

$node->validate(null);
@dg
Copy link
Member

dg commented Nov 18, 2020

I'm joining @matej21 here.

@dg
Copy link
Member

dg commented Nov 23, 2020

What is snippetArea without parameters used for?

@ikeblaster
Copy link
Author

@dg We used it to solve Dynamic snippets are allowed only inside static snippet/snippetArea.

Of course we can use {snippetArea xyz}, it works without any problems (and we have done that in our code). But it's still a minor BC issue.


More detailed example - not particularly elegant, but it worked for the desired result (redrawing individual controls in AJAX calls). If there is a better solution (which would cover all our needs), we haven't found it yet.

_blocks.latte

{define form $formName}
	{snippetArea}
		<form n:name="$formName" class="form-layout">
			<div n:foreach="$form->getControls() as $name => $input"
					n:snippet="$input->htmlId">

				{* custom controls rendering *}
			</div>
		</form>
	{/snippetArea}
{/define}

edit.latte

{import '_blocks.latte'}

{snippetArea exampleForm}
	{include form exampleForm}
{/snippetArea}

dg added a commit that referenced this issue Nov 23, 2020
@dg
Copy link
Member

dg commented Nov 23, 2020

fixed

@dg dg closed this as completed Nov 23, 2020
dg added a commit that referenced this issue Nov 23, 2020
@dg
Copy link
Member

dg commented Nov 23, 2020

Btw, I also removed exception ''Dynamic snippets are allowed only inside static snippet/snippetArea.' in 2.9-dev 77d4498 according to this issue #134. @matej21 is it safe?

dg added a commit that referenced this issue Nov 24, 2020
@matej21
Copy link
Contributor

matej21 commented Nov 24, 2020

@dg i think, you won't get any runtime error, so it might be harder to understand why it doesn't work.

@dg
Copy link
Member

dg commented Nov 25, 2020

I don't understand snippets at all (No longer) :-) So have I remove (#134 (comment)) or keep the check?

@matej21
Copy link
Contributor

matej21 commented Nov 25, 2020

@dg imho the check is not needed anymore for dynamic snippets to work, but it might be a useful hint for developer. The runtime check/hint could be implemented in snippet driver when renderingSnippets is false

@dg
Copy link
Member

dg commented Nov 25, 2020

Like this? 664a0f2

@matej21
Copy link
Contributor

matej21 commented Nov 25, 2020

@dg sth like this matej21@1d2796b

@dg
Copy link
Member

dg commented Nov 25, 2020

Thanks

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

3 participants