Skip to content
Advertisement

How to get word after user input in textarea?

I have a text area to user to insert text, but if the user type {{name}}, {{nickname}} and {{email}}. It must show the message with that value. Let me demonstrate: For example: If user type: Hello, {{name}} has {{nickname}} and {{email}} the message must be like this: Hello, user A has nickname A and email@gmail.com.

This is my blade view:

JavaScript

My controller:

JavaScript

Advertisement

Answer

This is an approach I’ve used in a number of projects to allow template input and functions that return replacements.

here, $subject is the text being modified.

JavaScript

You can then create functions that start with replace_ and return the string to be inserted in the original message

eg

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement