File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
slides_sources/source/exercises Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,42 @@ You can now render some ``<p>`` tags (and others) with attributes
162162
163163See ``test_html_output4.html ``
164164
165+ .. nextslide :: the "class" attribute.
166+
167+ NOTE: if you do "proper" CSS+html, then you wouldn't specify style directly in element attributes.
168+
169+ Rather you would set the "class" attribute::
170+
171+ <p class="intro">
172+ This is my recipe for making curry purely with chocolate
173+ </p>
174+
175+ However, if you try this as a keywork argument in Python:
176+
177+ .. code-block :: ipython
178+
179+ In [1]: P("some content", class="intro")
180+ File "<ipython-input-1-7d9a6b30cd26>", line 1
181+ P("some content", class="intro")
182+ ^
183+ SyntaxError: invalid syntax
184+
185+ Huh?
186+
187+ "class" is a reserved work in Python -- for making classes.
188+ So it can't be used as a keywork argument.
189+
190+ But it's a fine key in a dict, so you can put it in a dict, and pass it in with ``** ``:
191+
192+ .. code-block :: python
193+
194+ attrs = {' class' : ' intro' }
195+ P(" some content" , ** attrs)
196+
197+ You could also special-case this in your code -- so your users could use "clas"
198+ with one s, and you could tranlate it in the generated html.
199+
200+
165201Step 5:
166202--------
167203
You can’t perform that action at this time.
0 commit comments