Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions frontend/encore/simple-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ We'll use jQuery to print this message on the page. Install it via:

Great! Use ``require()`` to import ``jquery`` and ``greet.js``:

.. code-block:: diff
.. code-block:: javascript

// assets/js/app.js
// ...
// assets/js/app.js
// ...

+ // loads the jquery package from node_modules
+ var $ = require('jquery');
// loads the jquery package from node_modules
var $ = require('jquery');

+ // import the function from greet.js (the .js extension is optional)
+ // ./ (or ../) means to look for a local file
+ var greet = require('./greet');
// import the function from greet.js (the .js extension is optional)
// ./ (or ../) means to look for a local file
var greet = require('./greet');

+ $(document).ready(function() {
+ $('body').prepend('<h1>'+greet('jill')+'</h1>');
+ });
$(document).ready(function() {
$('body').prepend('<h1>'+greet('jill')+'</h1>');
});

That's it! If you previously ran ``encore dev --watch``, your final, built files
have already been updated: jQuery and ``greet.js`` have been automatically
Expand Down