Skip to content

Changing code block from diff to javascript #16058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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