Skip to content

Cleaner white space/indentation in templates#11866

Merged
mattpap merged 14 commits intobranch-3.0from
g-parki/11811_templates
Dec 16, 2021
Merged

Cleaner white space/indentation in templates#11866
mattpap merged 14 commits intobranch-3.0from
g-parki/11811_templates

Conversation

@g-parki
Copy link
Copy Markdown
Member

@g-parki g-parki commented Dec 8, 2021

So far my approach has been:

  1. Set trim_blocks=True, lstrip_blocks=True in the Jinja environment
  2. Add tests for immediate issue of white space at the top of HTML, and scripts being pulled up to the previous line
  3. Remove most block indentation from file.html
  4. Manually wrangle whatever didn't look right by selectively adding {% -%} or {%- %} or indent(x)
Initial before/after comparison Before: Screen Shot 2021-12-07 at 7 43 19 PM After: afterTemplate

@mattpap
Copy link
Copy Markdown
Contributor

mattpap commented Dec 8, 2021

@g-parki, please rebase this to resolve CI failures.

@mattpap mattpap added this to the 3.0 milestone Dec 8, 2021
@g-parki g-parki force-pushed the g-parki/11811_templates branch from 4e64ab5 to 186e948 Compare December 9, 2021 04:41
@g-parki
Copy link
Copy Markdown
Member Author

g-parki commented Dec 9, 2021

Noting the templates are mentioned in user_guide/embed.rst, so if review is OK then I'll be updating this as well.

@g-parki
Copy link
Copy Markdown
Member Author

g-parki commented Dec 9, 2021

Updated demo below. I'll dig more into the indentation of the inline case. @mattpap are there other use cases I should consider and/or test? So far I haven't had to modify existing tests, and this passes all.

Inline Before: Screen Shot 2021-12-08 at 9 02 21 PM After Screen Shot 2021-12-08 at 9 01 57 PM
CDN Before: Screen Shot 2021-12-08 at 9 02 50 PM After: Screen Shot 2021-12-08 at 9 03 05 PM
Server Before: Screen Shot 2021-12-08 at 9 05 22 PM After: Screen Shot 2021-12-08 at 9 05 04 PM

@mattpap
Copy link
Copy Markdown
Contributor

mattpap commented Dec 9, 2021

This would be pretty much perfect if root <div> and <script>s would align.

@bryevdv
Copy link
Copy Markdown
Member

bryevdv commented Dec 16, 2021

@g-parki unless you are aware of (or have reason to think there are) further improvements that are quick/simple, I would like to go ahead and merge this as it is (since it already represents a dramatic improvement) and leave any additional refinements to future PRs.

@g-parki
Copy link
Copy Markdown
Member Author

g-parki commented Dec 16, 2021

@bryevdv I have one tweak I'll try to push by end of day. If I don't get to it, no worries merging as-is 👍

@g-parki
Copy link
Copy Markdown
Member Author

g-parki commented Dec 16, 2021

@bryevdv assuming CI comes out good, I'll go ahead and give up for now 🥲
Peter Griffin frustrated at window blinds

@mattpap mattpap merged commit 5d39bb3 into branch-3.0 Dec 16, 2021
@mattpap mattpap deleted the g-parki/11811_templates branch December 16, 2021 18:27
bryevdv pushed a commit that referenced this pull request May 15, 2022
* Enable block trimming, add initial test

* Add test for script start/stops

* Trim comment blocks in templates

* Remove hard-coded white space in templates

* Minimize manual trimming/indenting

* Clean up indentation, standardize CSS/JS

* Simplify new template test

* Expand new test to cover multiple resource modes

* Reduce whitespace around title and scripts

* isort, lint test_templates

* Combine JS/CSS resource defs in test_templates

* Reduce indent of plot script

* Consistent indentation in template itself

* Update template in docs
@bryevdv bryevdv mentioned this pull request May 15, 2022
@bryevdv bryevdv modified the milestones: 3.0, 2.4.3 May 16, 2022
bryevdv added a commit that referenced this pull request May 16, 2022
* Update CONTRIBUTING.MD (#11957)

* track modified files in release build more carefully (#11972)

* Remove katex example (#11894)

* Remove katex example

* Remove test based on katex example

* Revert "Remove test based on katex example"

This reverts commit f0df5ed.

* Cleaner white space/indentation in templates (#11866)

* Enable block trimming, add initial test

* Add test for script start/stops

* Trim comment blocks in templates

* Remove hard-coded white space in templates

* Minimize manual trimming/indenting

* Clean up indentation, standardize CSS/JS

* Simplify new template test

* Expand new test to cover multiple resource modes

* Reduce whitespace around title and scripts

* isort, lint test_templates

* Combine JS/CSS resource defs in test_templates

* Reduce indent of plot script

* Consistent indentation in template itself

* Update template in docs

* 11726 Updated links to visjs.org Graph3d examples (#11728)

* Add sphinx_copybutton (#11993)

* Add sphinx_copybutton

* Update CI environments

* Move sphinx-copybutton to pip dependencies

* Fix typo in tools.py (#11935)

perfrom -> perform

* Fixed a few typos and changed wordings (#11698)

* Fix issue probably-meant-fstring found at https://codereview.doctor (#12097)

* add functools.wraps to _needs_document_lock_wrapper (#11976)

dask.distributed intermittently logs:
`RuntimeWarning: coroutine '_needs_document_lock.<locals>._needs_document_lock_wrapper' was never awaited`
with this wrapper it will be possible to see which method wasn't
awaited

* Md files checking and updating (#11903)

* Update readme

Resolving issue [#11868] (#11868)

* Update README.md

* Update README.md

* Update README.md

* Update commits with comments from #11903

* Update according to #1193 comments

* Update readme to comply code quality test

* update readme to comply code quality issues

* Elaborate on git commit/push process in docs (#11758)

* Add more git instructions

* Fix typo in models contributor guide

* Update sphinx/source/docs/dev_guide/pull_requests.rst

Co-authored-by: Timo Cornelius Metzger <39711796+tcmetzger@users.noreply.github.com>

Co-authored-by: Timo Cornelius Metzger <39711796+tcmetzger@users.noreply.github.com>

* Hover tooltips for Patch and Areas (#11992)

* Initial functioning WIP

* WIP Patch and HArea

* check for potentially null value

* Remove commented out code

* remove unnecessary to_screen call

* break after successful polygon hit test

* Add a comment regarding selection.is_empty()

Co-authored-by: Mateusz Paprocki <mattpap@gmail.com>

* Remove references to gen.coroutine from docs and update without_document_lock decorator (#12010)

* Update without_document_lock to decorate async functions and asyncio.coroutines as well

* Update docs to use async functions instead of tornado.gen.coroutines

* Add fact that async funcs are accepted in docstring

* Add test for async func decorated by without_document_lock

* Remove trailing whitespace

* simplify CI jobs with composite action (#11833)

* simplfy CI jobs with composite action

* lower verbosity on unpack

* Removed unnecessary calls to _recompute_all_models() to speed up adding roots (#11739)

* Removed unnecessary calls to _recompute_all_models() to speed up adding roots

* Corrected last commit so that general calls to add_root() still call recompute_all_models(), and that is only worked around in special situations.

* Wrapping calls to add_root() within push_all_models_freeze()

* Made last commit more elegant by getting rid of loop

Co-authored-by: Efrem Braun <efrem.braun@gmail.comm>

Co-authored-by: Timo Cornelius Metzger <39711796+tcmetzger@users.noreply.github.com>
Co-authored-by: g-parki <61096711+g-parki@users.noreply.github.com>
Co-authored-by: Bill <35750915+roadswitcher@users.noreply.github.com>
Co-authored-by: Ikko Ashimine <eltociear@gmail.com>
Co-authored-by: Harold <eldrickmargarejo@gmail.com>
Co-authored-by: code-review-doctor <72647856+code-review-doctor@users.noreply.github.com>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: girolamo <58935223+girolamodaschio@users.noreply.github.com>
Co-authored-by: Alex Pilon <alex.pilon@gmail.com>
Co-authored-by: Mateusz Paprocki <mattpap@gmail.com>
Co-authored-by: Ben Russell <bprussell80@protonmail.com>
Co-authored-by: Efrem Braun <efrem.braun@gmail.com>
Co-authored-by: Efrem Braun <efrem.braun@gmail.comm>
@github-actions
Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove unnecessary whitespace from rendered templates

3 participants