From 7f9be0bf1850a93c240f68cdfeee869a73abf588 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 2 Nov 2021 20:59:15 +0100 Subject: [PATCH] Changing code block from `diff` to `javascript` Reason: The `+` characters make it hard to copy-paste (and harder to read, since no syntax highlighting). Furthermore, I'm suggesting to remove jQuery from here. This is the first JavaScript example in this chapter, and it should be as basic as possible. --- frontend/encore/simple-example.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/encore/simple-example.rst b/frontend/encore/simple-example.rst index da99febb9b6..f7b261a491b 100644 --- a/frontend/encore/simple-example.rst +++ b/frontend/encore/simple-example.rst @@ -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('

'+greet('jill')+'

'); - + }); + $(document).ready(function() { + $('body').prepend('

'+greet('jill')+'

'); + }); 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