Comments (10)
Not with the current version (because it outputs directly to a string). However, most (all?) modern browsers allow you to look at the DOM of the page. Viewing the raw source usually isn't necessary.
from hiccup.
Can't newline characters with correct indentation be added for making the initial HTML document readable?
When using a framework it adds a lot of custom elements/attributes making debugging harder if we are depending on the web inspector.
from hiccup.
Can't newline characters with correct indentation be added for making the initial HTML document readable?
No, because it outputs directly to strings. In order to produce correct indentation you need the whole DOM, which is planned for version 2.0.
from hiccup.
👍
from hiccup.
It would definitely be nice to have some minify options with hiccup. I don't necessarily need unminified but I would like an option to have a space between each element to help with spacing problems that can result from having no whitespace between elements such as this bootstrap issue: twbs/bootstrap#14401
from hiccup.
I wrote this library to deal with this: https://github.com/px0/clj-beautify-web
I usually put something like this in the render chain after the html
macro:
(fn [html]
(if (= "production" (:environment render-params))
html
(beautify-web.core/beautify-html html)))
from hiccup.
Is this planned for 2.0 ?
from hiccup.
No, plans for 2.0 were scaled back. Adding it in for 2.1 is a possibility, but I haven't had much time to work on Hiccup recently.
from hiccup.
Ah I see. Okay, thank you, I'll look into beautify-html for my debugging purpose.
from hiccup.
I'm also interested in such a built-in feature as I find readable formatting more convenient for unit tests and sometimes look at the source code instead of a browser inspector. The current workaround is to use Jericho to postformat the generated HTML:
[net.htmlparser.jericho/jericho-html "3.4"]
...
(:import [net.htmlparser.jericho Source])
...
(defn formatted-html
[s]
(str (-> (.getSourceFormatter (Source. s))
(.setIndentString " "))))
from hiccup.
Related Issues (20)
- Null pointer exception with `:class` attribute containing vector nil HOT 3
- Replace license.html with license.txt (for artifact scanners) HOT 9
- Passing nil query param values to to url-encode throws exception
- New version? HOT 15
- :script async HOT 1
- Clojerl support HOT 2
- Historical question: Why is hiccup called hiccup? HOT 2
- link to api docs in project description is broken HOT 3
- Please remove.
- Fragment equivalent for the back end. HOT 2
- *escape-strings?* HOT 1
- hiccup.core/h not backward-compatible HOT 1
- Getting RuntimeException: no such var util/raw-string HOT 2
- Parameters for iframe src attribute HOT 8
- clj-kondo exported config HOT 4
- void-tags might not be complete HOT 3
- "Method code too large!" when compiling the hiccup2.core/html macro HOT 1
- Exponential increase in generated code when there are multiple nested hiccup2.core/html calls HOT 4
- Style attribute with a map as value: doesn't evaluate code within the map
- Sentence needed in readme.md to clarify status of original hiccup namespaces, when using hiccup2? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hiccup.