statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.7k stars 508 forks source link

partial:exists tag fails in nested partials #4993

Closed beck24 closed 2 years ago

beck24 commented 2 years ago

Bug description

Facade\Ignition\Exceptions\ViewException
View [exists] not found.

Using a conditional for whether the partial exists as per the documentation here:

https://statamic.dev/tags/partial-exists

I get this exception, it appears it's not treating it as it's own tag, but attempting to use the shorthand {partial:path/to/view} and the view 'exists' doesn't exist. I'm using it exactly as documented though, so I can't see how it's user error (though if it is please do let me know how/where).

How to reproduce

This is the relevant part of my template

{{ if {partial:exists src="inputs/select"} }}
    It exists
{{ else }}
    It doesn't exist
{{ /if }}

Logs

[previous exception] [object] (InvalidArgumentException(code: 0): View [exists] not found. at /var/www/html/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php:137)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php(79): Illuminate\\View\\FileViewFinder->findInPaths('exists', Array)
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Factory.php(138): Illuminate\\View\\FileViewFinder->find('exists')
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(932): Illuminate\\View\\Factory->make('exists', Array, Array)
#3 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(23): view('exists', Array)
#4 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(13): Statamic\\Tags\\Partial->render('exists')
#5 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(65): Statamic\\Tags\\Partial->wildcard('exists')
#6 [internal function]: Statamic\\Tags\\Partial->exists()
#7 /var/www/html/vendor/statamic/cms/src/View/Antlers/Engine.php(159): call_user_func(Array)
#8 [internal function]: Statamic\\View\\Antlers\\Engine::renderTag(Object(Statamic\\View\\Antlers\\Parser), 'partial', Array, '', Array)
#9 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(578): call_user_func_array(Array, Array)
#10 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(827): Statamic\\View\\Antlers\\Parser->parseCallbackTags('{partial:exists...', Array)
#11 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(696): Statamic\\View\\Antlers\\Parser->processCondition('{partial:exists...', Array)
#12 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(172): Statamic\\View\\Antlers\\Parser->parseConditionPairs('<div x-data=\"{\
...', Array)
#13 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(132): Statamic\\View\\Antlers\\Parser->parse('<div x-data=\"{\
...', Array)
#14 /var/www/html/vendor/statamic/cms/src/View/Antlers/Engine.php(95): Statamic\\View\\Antlers\\Parser->parseView('/var/www/html/r...', '<div x-data=\"{\
...', Array)
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(139): Statamic\\View\\Antlers\\Engine->get('/var/www/html/r...', Array)
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(122): Illuminate\\View\\View->getContents()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(91): Illuminate\\View\\View->renderContents()
#18 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(25): Illuminate\\View\\View->render()
#19 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(84): Statamic\\Tags\\Partial->render('partials/conten...')
#20 [internal function]: Statamic\\Tags\\Partial->ifExists()
#21 /var/www/html/vendor/statamic/cms/src/View/Antlers/Engine.php(159): call_user_func(Array)
#22 [internal function]: Statamic\\View\\Antlers\\Engine::renderTag(Object(Statamic\\View\\Antlers\\Parser), 'partial', Array, '', Array)
#23 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(578): call_user_func_array(Array, Array)
#24 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(341): Statamic\\View\\Antlers\\Parser->parseCallbackTags('            {{ ...', Array)
#25 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(288): Statamic\\View\\Antlers\\Parser->parseLoopInstance('            {{ ...', Array)
#26 [internal function]: Statamic\\View\\Antlers\\Parser->Statamic\\View\\Antlers\\{closure}(Array, 0)
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(664): array_map(Object(Closure), Array, Array)
#28 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(289): Illuminate\\Support\\Collection->map(Object(Closure))
#29 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(223): Statamic\\View\\Antlers\\Parser->parseLoopVariables('        <div cl...', Array)
#30 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(339): Statamic\\View\\Antlers\\Parser->parseVariables('        <div cl...', Array)
#31 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(288): Statamic\\View\\Antlers\\Parser->parseLoopInstance('        <div cl...', Array)
#32 [internal function]: Statamic\\View\\Antlers\\Parser->Statamic\\View\\Antlers\\{closure}(Array, 0)
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(664): array_map(Object(Closure), Array, Array)
#34 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(289): Illuminate\\Support\\Collection->map(Object(Closure))
#35 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(223): Statamic\\View\\Antlers\\Parser->parseLoopVariables('{{ columns }}\
 ...', Array)
#36 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(175): Statamic\\View\\Antlers\\Parser->parseVariables('{{ columns }}\
 ...', Array)
#37 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(132): Statamic\\View\\Antlers\\Parser->parse('{{ columns }}\
 ...', Array)
#38 /var/www/html/vendor/statamic/cms/src/View/Antlers/Engine.php(95): Statamic\\View\\Antlers\\Parser->parseView('/var/www/html/r...', '{{ columns }}\
 ...', Array)
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(139): Statamic\\View\\Antlers\\Engine->get('/var/www/html/r...', Array)
#40 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(122): Illuminate\\View\\View->getContents()
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(91): Illuminate\\View\\View->renderContents()
#42 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(25): Illuminate\\View\\View->render()
#43 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(13): Statamic\\Tags\\Partial->render('partials/column...')
#44 /var/www/html/vendor/statamic/cms/src/Tags/Tags.php(138): Statamic\\Tags\\Partial->wildcard('partials/column...')
#45 [internal function]: Statamic\\Tags\\Tags->__call('partials/column...', Array)
#46 /var/www/html/vendor/statamic/cms/src/View/Antlers/Engine.php(159): call_user_func(Array)
#47 [internal function]: Statamic\\View\\Antlers\\Engine::renderTag(Object(Statamic\\View\\Antlers\\Parser), 'partial', Array, '', Array)
#48 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(578): call_user_func_array(Array, Array)
#49 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(341): Statamic\\View\\Antlers\\Parser->parseCallbackTags('            <di...', Array)
#50 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(288): Statamic\\View\\Antlers\\Parser->parseLoopInstance('            <di...', Array)
#51 [internal function]: Statamic\\View\\Antlers\\Parser->Statamic\\View\\Antlers\\{closure}(Array, 0)
#52 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(664): array_map(Object(Closure), Array, Array)
#53 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(289): Illuminate\\Support\\Collection->map(Object(Closure))
#54 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(223): Statamic\\View\\Antlers\\Parser->parseLoopVariables('<div class=\"\
  ...', Array)
#55 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(175): Statamic\\View\\Antlers\\Parser->parseVariables('<div class=\"\
  ...', Array)
#56 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(132): Statamic\\View\\Antlers\\Parser->parse('<div class=\"\
  ...', Array)
#57 /var/www/html/vendor/statamic/cms/src/View/Antlers/Engine.php(95): Statamic\\View\\Antlers\\Parser->parseView('/var/www/html/r...', '<div class=\"\
  ...', Array)
#58 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(139): Statamic\\View\\Antlers\\Engine->get('/var/www/html/r...', Array)
#59 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(122): Illuminate\\View\\View->getContents()
#60 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(91): Illuminate\\View\\View->renderContents()
#61 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(25): Illuminate\\View\\View->render()
#62 /var/www/html/vendor/statamic/cms/src/Tags/Partial.php(13): Statamic\\Tags\\Partial->render('partials/sectio...')
#63 /var/www/html/vendor/statamic/cms/src/Tags/Tags.php(138): Statamic\\Tags\\Partial->wildcard('index')
#64 [internal function]: Statamic\\Tags\\Tags->__call('index', Array)
#65 /var/www/html/vendor/statamic/cms/src/View/Antlers/Engine.php(159): call_user_func(Array)
#66 [internal function]: Statamic\\View\\Antlers\\Engine::renderTag(Object(Statamic\\View\\Antlers\\Parser), 'partial', Array, '', Array)
#67 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(578): call_user_func_array(Array, Array)
#68 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(341): Statamic\\View\\Antlers\\Parser->parseCallbackTags('        {{ part...', Array)
#69 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(288): Statamic\\View\\Antlers\\Parser->parseLoopInstance('        {{ part...', Array)
#70 [internal function]: Statamic\\View\\Antlers\\Parser->Statamic\\View\\Antlers\\{closure}(Array, 5)
#71 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(664): array_map(Object(Closure), Array, Array)
#72 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(289): Illuminate\\Support\\Collection->map(Object(Closure))
#73 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(223): Statamic\\View\\Antlers\\Parser->parseLoopVariables('    {{ section ...', Array)
#74 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(175): Statamic\\View\\Antlers\\Parser->parseVariables('    {{ section ...', Array)
#75 /var/www/html/vendor/statamic/cms/src/View/Antlers/Parser.php(132): Statamic\\View\\Antlers\\Parser->parse('    {{ section ...', Array)
#76 /var/www/html/vendor/statamic/cms/src/View/Antlers/Engine.php(95): Statamic\\View\\Antlers\\Parser->parseView('/var/www/html/r...', '{{ if section}}...', Array)
#77 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(139): Statamic\\View\\Antlers\\Engine->get('/var/www/html/r...', Array)
#78 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(122): Illuminate\\View\\View->getContents()
#79 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(91): Illuminate\\View\\View->renderContents()
#80 /var/www/html/vendor/statamic/cms/src/View/View.php(89): Illuminate\\View\\View->render()
#81 /var/www/html/vendor/statamic/cms/src/Http/Responses/DataResponse.php(154): Statamic\\View\\View->render()
#82 /var/www/html/vendor/statamic/cms/src/Http/Responses/DataResponse.php(45): Statamic\\Http\\Responses\\DataResponse->contents()
#83 /var/www/html/vendor/statamic/cms/src/Structures/Page.php(377): Statamic\\Http\\Responses\\DataResponse->toResponse(Object(Illuminate\\Http\\Request))
#84 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(776): Statamic\\Structures\\Page->toResponse(Object(Illuminate\\Http\\Request))
#85 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(763): Illuminate\\Routing\\Router::toResponse(Object(Illuminate\\Http\\Request), Object(Statamic\\Structures\\Page))
#86 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\\Routing\\Router->prepareResponse(Object(Illuminate\\Http\\Request), Object(Statamic\\Structures\\Page))
#87 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#88 /var/www/html/vendor/statamic/cms/src/StaticCaching/Middleware/Cache.php(34): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#89 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\StaticCaching\\Middleware\\Cache->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#90 /var/www/html/vendor/statamic/cms/src/Http/Middleware/AuthGuard.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#91 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\AuthGuard->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#92 /var/www/html/vendor/statamic/cms/src/Http/Middleware/Localize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#93 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\Localize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#94 /var/www/html/vendor/statamic/cms/src/Http/Middleware/StacheLock.php(29): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#95 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\StacheLock->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#96 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#97 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#98 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#99 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#100 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#101 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#102 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#103 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest(Object(Illuminate\\Http\\Request), Object(Illuminate\\Session\\Store), Object(Closure))
#104 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#105 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#106 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#107 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#108 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#109 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#110 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#111 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#112 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#113 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#114 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#115 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#116 /var/www/html/vendor/statamic/cms/src/Http/Middleware/DisableFloc.php(18): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#117 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\DisableFloc->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#118 /var/www/html/vendor/statamic/cms/src/Http/Middleware/CheckMultisite.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#119 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\CheckMultisite->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#120 /var/www/html/vendor/statamic/cms/src/Http/Middleware/CheckComposerJsonScripts.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#121 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\CheckComposerJsonScripts->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#122 /var/www/html/vendor/statamic/cms/src/Http/Middleware/PoweredByHeader.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#123 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\PoweredByHeader->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#124 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#125 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#126 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#127 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#128 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#129 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#130 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#131 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#132 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#133 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#134 /var/www/html/vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#135 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#136 /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#137 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#138 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#139 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#140 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#141 /var/www/html/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#142 {main}
"}

Versions

Statamic 3.2.28 Pro Laravel 8.77.1 PHP 7.4.26 arckinteractive/statamic-bard-custom-class dev-master arckinteractive/statamic-bard-font-size 1.0.0 arckinteractive/statamic-bard-font-weight 1.0.1 doublethreedigital/duplicator 2.0.1 goldnead/statamic-collapse-fieldtype 1.0.4 optimoapps/statamic-bard-text-align 1.0.2 xndbogdan/statamic-bard-text-color 2.2

Installation

Existing Laravel app

Additional details

No response

jasonvarga commented 2 years ago

Weird. Can you provide the rest of the template?

beck24 commented 2 years ago

Sure, kind of, I've been trying to work around it but I'm still getting the error when I do this:

{{ if {partial:exists src="forms/{form.handle}"} }}
    {{ partial src="forms/{form.handle}"}}
{{ else }}
    {{ form:create in="{ form.handle }" }}
        {{ fields }}
            <div class="p-2">
                <label>
                {{ display }}
                {{ if validate | contains:required }}
                   <sup class="text-red">*</sup>
                {{ /if }}
                </label>
                <div class="p-1">{{ field }}</div>
                {{ if error }}
                    <p class="text-gray-500">{{ error }}</p>
                {{ /if }}
            </div>
        {{ /fields }}

    <input type="submit" value="Submit">
    {{ /form:create }}
{{ /if }}

What I'm trying to do is build a view that handles generic forms created by a user in the CMS. However there are a couple of specific forms that are going to need some specific template handling, so I wanted to make it so I could just create the template based on the form handle and drop it in.

Instead I'm having to do something like:

{{ if form.handle === 'specific_form_1' }}
    {{ partial:forms/specific_form_1 }}
{{ elseif form.handle === 'specific_form_2' }}
    {{ partial:forms/specific_form_2 }}
{{ else }}
    // generic template
{{ /if }}

But as you can see, new specific forms would need both a new template and be added to this if/else statement in this template. The only thing I can think of is that in other views rendered before this I have already used the {{ partial:path/to/view }} shorthand syntax. Could using the shorthand previously be affecting how this is interpreted? It shouldn't :)

beck24 commented 2 years ago

Also possibly relevant {{ partial:if_exists src="path/to/view" }} appears to be working just fine, it just doesn't have an else that I need

beck24 commented 2 years ago

Digging into the Statamic code a bit here.

if (! $partial = $this->params->get('src')) {
    return $this->wildcard('exists');
}

This is why it's trying to render a view called 'exists' - because $partial is null, but it's clearly being passed. I've even taken out the variable to pass an explicit string that I know resolves to a valid view.

Digging further this is because this is called from within a partial, it's a nested partial.

eg.

// template
{{ partial src="partial1" }}

// partial 1
{{ if {partial:exists src="maybe/exists/partial2"} }}
    // now we're hitting the exception
{{ /if }}

Now the Partial tag for the exists check gets the following parameters:

 [ 'partial1' => 'maybe/exists/partial2' ]

Instead of the expected

 ['src' => 'maybe/exists/partial2']
jasonvarga commented 2 years ago

Nice detective work!