2

Is it possible to insert the ButtonSend var inside my <input> part? This way will not work:

var ButtonSend = <?php _e('Go!', $this->plugin_slug) ?>;
LangKeys['en']['button'] = '<input v-on:click.prevent="submit" type="button" value="ButtonSend" />';

1 Answer 1

1

Assuming it's a string value (from the context of the property name) you need to wrap the PHP output in quotes. Then you can concatenate the value as you would any other:

var ButtonSend = '<?php _e('Go!', $this->plugin_slug) ?>';
LangKeys.en.button = '<input v-on:click.prevent="submit" type="button" value="' + ButtonSend + '" />';

Alternatively you could use a template literal to do the concatenation, assuming you don't need IE support:

LangKeys.en.button = '<input v-on:click.prevent="submit" type="button" value="${ButtonSend}" />';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.