Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mpjraaij's avatar

Using {{ }} for blade and @{{ }} for vue in new component

Hi there,

In all Spark templates there's a distinct difference between using {{ }} (blade) and @{{ }} (vue).

So whenever I use {{ trans('messages.welcome') }} it activates blade to hit the trans method.

I've just created my own component in Vue:

Vue.component('update-team-contact-information', { props: ['team'] });

However if I'd do this, I get an error (see below):

<update-team-contact-information :team="team" inline-template> {{ trans('messages.welcome') }} </update-team-contact-information>

The error:

[Vue warn]: Property or method "trans" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in component <update-team-contact-information>)

How can I make it so that in my own component {{ }} is used for blade and @{{ }} is used for vue?

0 likes
7 replies
mahmandev's avatar

That's weird. I'm doing the exact same thing and it works fine.

mahmandev's avatar

Try to wrap everything inside the template with a div.

mpjraaij's avatar

Thanks for your answer!

<spark-update-team-contact-information :team="team" inline-template>
    <div class="panel panel-default">
        <div class="panel-body">
            <h5 class="text-center m-t-xs m-b-lg">{{ trans('auth.header.team') }}</h5>
        </div>
    </div>
</spark-update-team-contact-information>

Still gives:

[Vue warn]: Property or method "trans" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in component <spark-update-team-contact-information>)

[Vue warn]: Error when rendering component <spark-update-team-contact-information>:

TypeError: trans is not a function

It seems like blade is not rendering this template somehow, only vue is. Other php variables that should be passed on with blade aren't working either.

willvincent's avatar

Is that actually a blade template? You've not really provided any context as to where/how you're implementing this. If it's not a blade template, then of course blade isn't going to process it. :)

Where is this template defined? Is it pulled in by blade somewhere (and include, etc) or is this strictly just a vue template that is never interpreted by the blade engine?

ejdelmonico's avatar

Question: how is blade supposed to render the trans method when blade is not used when creating the component? You must define the method in the component I believe.

mpjraaij's avatar

Thanks everyone, after looking over each aspect, in the end I discovered there was no '.blade' in the filename.

1 like

Please or to participate in this conversation.