Create block of program with variables to autofill



I have the following code (using laravel):

{!! Form::label(‘customer_location’, ‘Customer location’, [‘class’ => ‘control-label’]) !!}

{!! Form::text(‘customer_location’, (isset($project)) ? $project->customer_location : ‘’, [‘class’ => ‘form-control’, ‘placeholder’ => ‘customer_location’]) !!}
{!! $errors->first(‘customer_location’, ‘:message’) !!}

I would like to be able to insert this by just entering 2 variables (the table reference which is here customer_location and the title which is customer location) and then Atom would insert the code with those 2 variables I gave.

How can it be done?




You can achieve this with the snippets functionality.

  'Customer Location':
    prefix: 'cus'
    body: """
{!! Form::label('$1', '$2', ['class' => 'control-label']) !!}
{!! Form::text('$1', (isset(\$project)) ? \$project->$1 : '', ['class' => 'form-control', 'placeholder' => '$1']) !!}
{!! \$errors->first('$1', ':message') !!}$3

You can start writing cus, press tab to get the code snippet with five cursors so that you can enter all five occurrences of the table reference, press tab again and you’ll have a cursor to enter the title, then tab once more to reach the end.