Správná syntaxe pro kompilování latte s HTML a PHP

fanatik
Člen | 3
+
0
-

Zdravím,
potreboval bych poradit, jaká je správná syntaxe pro vkládání podmínek s HTML kódem.
Tracy mi vyhazuje error, že je potřeba každý tag uzavřít, ale já ho potřebuju uzavírat až po podmínce.

{* zpracovani formulare *}
{form $form, role => form}
	{* vygenerovani formularovych prvku *}
	{capture $html_items}
		{control $form errors}
		{if !empty($form->getGroups())}
			{foreach $form->getGroups() as $group}
				{if isset($group->getOptions()["label"])}
					{if $groupIndex == 0}
						<div class="row">
					{/if}
				{var $groupIndex = $groupIndex + 1}
					<div class="col-md-{isset($group->getOptions()["col"]) ? $group->getOptions()["col"] : '6'}">
						{if $group->getOptions()["label"] != "__SIMPLE__"}
						<div class="panel panel-default">
							<div class="panel-heading">{$group->getOptions()["label"]|noescape}</div>
							<div class="panel-body">
								<div class="row">
									<div class="col-md-12">
										{/if}
										{foreach $group->getControls() as $item}
											{if $item instanceof \Nette\Forms\Controls\HiddenField}
												{input $item->name, class => hide}
											{elseif $item instanceof \ExtendedForm\Submit}
												{var $buttons[] = $item}
											{elseif $item instanceof \ExtendedForm\Button}
												{var $buttons[] = $item}
											{elseif $item instanceof \ExtendedForm\Phone}
												{include inputPhone, item => $item}
											{elseif $item instanceof \ExtendedForm\Login}
												{include inputLogin, item => $item}
											{elseif $item instanceof \ExtendedForm\Password}
												{include inputPassword, item => $item}
											{elseif $item instanceof \ExtendedForm\DateTime}
												{include inputDateTime, item => $item}
											{elseif $item instanceof \ExtendedForm\RadioList}
												{include inputRadioList, item => $item}
											{elseif $item instanceof \ExtendedForm\Files}
												{include inputFiles, item => $item}
											{elseif $item instanceof \ExtendedForm\Checkbox}
												{include inputCheckbox, item => $item}
											{elseif $item instanceof \ExtendedForm\CheckboxList}
												{include inputCheckboxList, item => $item}
											{elseif $item instanceof \ExtendedForm\Upload}
												{include inputUpload, item => $item}
											{elseif $item instanceof \ExtendedForm\Editable}
												{include inputEditable, item => $item}
											{elseif $item instanceof \ExtendedForm\Dropzone}
												{include inputDropzone, item => $item}
											{else}
												{include inputDefault, item => $item}
											{/if}
										{/foreach}
										{if $group->getOptions()["label"] != "__SIMPLE__"}
									</div>
								</div>
							</div>
						</div>
						{/if}
					</div>
					{if $groupIndex == 2}
						</div>
						{var $groupIndex = 0;}
					{/if}
				{else}
					<div class="row">
						<div class="col-md-12">
							{foreach $group->getControls() as $item}
								{if $item instanceof \Nette\Forms\Controls\HiddenField}
									{input $item->name, class => hide}
								{elseif $item instanceof \ExtendedForm\Submit}
									{var $buttons[] = $item}
								{elseif $item instanceof \ExtendedForm\Button}
									{var $buttons[] = $item}
								{elseif $item instanceof \ExtendedForm\Password}
									{include inputPassword, item => $item}
								{elseif $item instanceof \ExtendedForm\Login}
									{include inputLogin, item => $item}
								{elseif $item instanceof \ExtendedForm\Phone}
									{include inputPhone, item => $item}
								{elseif $item instanceof \ExtendedForm\DateTime}
									{include inputDateTime, item => $item}
								{elseif $item instanceof \ExtendedForm\RadioList}
									{include inputRadioList, item => $item}
								{elseif $item instanceof \ExtendedForm\Checkbox}
									{include inputCheckbox, item => $item}
								{elseif $item instanceof \ExtendedForm\CheckboxList}
									{include inputCheckboxList, item => $item}
								{elseif $item instanceof \ExtendedForm\Upload}
									{include inputUpload, item => $item}
								{elseif $item instanceof \ExtendedForm\Editable}
									{include inputEditable, item => $item}
								{elseif $item instanceof \ExtendedForm\Files}
									{include inputFiles, item => $item}
								{elseif $item instanceof \ExtendedForm\Dropzone}
									{include inputDropzone, item => $item}
								{else}
									{include inputDefault, item => $item}
								{/if}
							{/foreach}
						</div>
					</div>
				{/if}
			{/foreach}
		{else}
			{if $row}
				<div class="row"><div class="col-md-12">
			{/if}
			{foreach $form->components as $item}
				{if $item instanceof \Nette\Forms\Controls\HiddenField}
					{input $item->name, class => hide}
				{elseif $item instanceof \ExtendedForm\Submit}
					{var $buttons[] = $item}
				{elseif $item instanceof \ExtendedForm\Button}
					{var $buttons[] = $item}
				{elseif $item instanceof \ExtendedForm\Phone}
					{include inputPhone, item => $item}
				{elseif $item instanceof \ExtendedForm\Login}
					{include inputLogin, item => $item}
				{elseif $item instanceof \ExtendedForm\Password}
					{include inputPassword, item => $item}
				{elseif $item instanceof \ExtendedForm\DateTime}
					{include inputDateTime, item => $item}
				{elseif $item instanceof \ExtendedForm\RadioList}
					{include inputRadioList, item => $item}
				{elseif $item instanceof \ExtendedForm\Checkbox}
					{include inputCheckbox, item => $item}
				{elseif $item instanceof \ExtendedForm\CheckboxList}
					{include inputCheckboxList, item => $item}
				{elseif $item instanceof \ExtendedForm\Upload}
					{include inputUpload, item => $item}
				{elseif $item instanceof \ExtendedForm\Editable}
					{include inputEditable, item => $item}
				{elseif $item instanceof \ExtendedForm\Files}
					{include inputFiles, item => $item}
				{elseif $item instanceof \ExtendedForm\Dropzone}
					{include inputDropzone, item => $item}
				{else}
					{include inputDefault, item => $item}
				{/if}
			{/foreach}
			{if $row}
				</div></div>
			{/if}
		{/if}
	{/capture}
	{* vygenerovani tlacitek *}
	{capture $html_buttons}
		{foreach $buttons as $button}
			{input $button->name}
		{/foreach}
	{/capture}
	{* vykresleni formulare *}
	{*if $form->isDropzone()}
		{$html_items|noescape}
	{else*}
	{if $dialog && !empty($title)}
		<div class="modal fade" id="{$form->name}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="myModalLabel">{$title|noescape}</h4>
					</div>
					<div class="modal-body">
						{$html_items|noescape}
						{ifset $modal_text}<p>{$modal_text|noescape}</p>{/ifset}
					</div>
					<div class="modal-footer">
						{$html_buttons|noescape}
						<button type="button" class="btn btn-danger" data-dismiss="modal">Zavřít</button>
					</div>
				</div>
			</div>
		</div>
	{else}
		{if !empty($title)}
			<div class="row">
				<div class="col-md-12">
					<h1 class="page-header">{$title}</h1>
				</div>
			</div>
		{/if}
		{$html_items|noescape}
		{$html_buttons|noescape}
	{/if}
	{*/if*}
{/form}

Error z Tracy zde:
":https://ctrlv.cz/ZlsY

Děkuji.

Pavel Kravčík
Člen | 1194
+
+1
-

Zkus mrknout na tohle. V tom kódu se s těmi komentáři špatně čte, zkus debugovat po menších částech možná.

https://blog.nette.org/…riktni-rezim
https://blog.nette.org/…ivas-a-batch

fanatik
Člen | 3
+
+1
-

Pavel Kravčík napsal(a):

Zkus mrknout na tohle. V tom kódu se s těmi komentáři špatně čte, zkus debugovat po menších částech možná.

https://blog.nette.org/…riktni-rezim
https://blog.nette.org/…ivas-a-batch

Ty jo, dík moc. To bylo rychlé a efektivní :)