Comments (18)
There is no input type textbox.
http://www.w3.org/TR/html401/sgml/dtd.html#InputType
You are probably looking for <textarea>?
from jquery-tmpl.
No, it was text.. However, that isnt the point. The actual generated output by this plugin does not preserve the line breaks that are in the template. I have the examples in this but github isnt recognizing the code..
from jquery-tmpl.
Is it safe to assume you mean the markup itself is not formatted when returned?
If so, why would it need to be? Considering it's generated content, is there really any benefit to having it come out pretty? Any further interaction with the resulting markup would normally be through the UI it creates or an element inspector (such as that in Firebug or Chrome) which display the DOM in a tree structure.
Am I missing something?
BTW: Indent your code by 4 spaces on every line to have it print out properly in your comments. See the docs for GitHub Flavored Markdown -- link at the bottom-right, under the comment textarea.
from jquery-tmpl.
In those input[type=text] it wouldn’t matter, but for <pre>-style blocks it would.
But I dunno if he was referring to that, as he didn’t seem to …
from jquery-tmpl.
@coiscir: Yes, you are correct. I believe this plugin should preserve the line breaks that are in the template. I don't want to be dependent on some third party plugin to auto-format my source code. It's much faster for me to ctrl+a ctrl+u to view my source.
@Kissaki: Again, it's not the value of the input I am talking about, merely the line breaks between the tags.
from jquery-tmpl.
@coiscir I have 4 points about it:
- as @Kissaki already said about pre tags
- template engine shouldn't modify markup in places user doesn't expect it. I think the correct behaviour is also not to prettify the output, but to leave it as it is.
- practical example would be: if I want to debug the generated markup, I want to see its string representation, not a rendered by browser dom view, because its not the same. So if you cut the new lines etc. its all 1 line then and is difficult to read.
- another use case: I maintain nodejs port of jquery-tmpl, https://github.com/kof/node-jqtpl, html is rendered serverside and the output is always 1 line, which is difficult to inspect without to render it by browser and then use firebug.
from jquery-tmpl.
Indeed, a template function should only do that, templating, and not more logic like minimizing.
It should only do so if a parameter or the function(name) indicates it is also minifying.
from jquery-tmpl.
imho this is a very serious issue that doesn't seem to be getting any attention? Is there some reason that a simple fix isn't available? Seems like it wouldn't be too bad (but I don't know).
from jquery-tmpl.
I want this as well, but for different reasons. I'm appending my output to a textarea and was expecting my linebreaks in my template to go over to my textarea. As it is right now it's all on a single line. Only way to work around this in the current state is to have separate templates for each section with manual line breaks inserted at the end. Be a lot nicer if white space was preserved.
from jquery-tmpl.
I do believe the issue is here: https://github.com/jquery/jquery-tmpl/blob/master/jquery.tmpl.js#L326
Not able to test at the moment, let me know if anyone can confirm this.
from jquery-tmpl.
Yes, you are right. That line was there from the beginning - in John Resig's original prototype. It reflects the philosophy that the goal it to guarantee HTML visual layout, but not to preserve 'pretty printing' or similar of HTML.
We can consider changing that philosophy. I agree that there are scenarios where it is valuable to maintain that fidelity. I am happy to keep this issue, open, (so will open it again now), particularly as I am planning to make rendering to an HTML string a lot easier to achieve in the Beta2 version. (We hope to release a Beta2 in April.)
from jquery-tmpl.
Allowing for pruning via a parameter(/option) would be a viable solution.
from jquery-tmpl.
what happenned to this issue? is it solved?
from jquery-tmpl.
@BorisMoore - how can the content of <pre>
or <textarea>
tags not considered as part of the HTML visual layout?
Why does the plugin bother stripping out the original linebreaks anyway? What purpose does that serve exactly?
from jquery-tmpl.
Several reasons, such as that in the conversion to code, for creating a compiled function, line breaks can lead to JS errors, missing string delimiters, etc. Supporting them would have added additional code for compilation.
In the ongoing work at JsRender and JsViews I am currently working on a different compilation approach which may allow me to provide a mode that preserves white space.... (See #96 for context re: roadmap).
from jquery-tmpl.
Oh right I forgot JS doesn't really roll with multiline strings. Having said that, why not a trivial fix like so:
diff --git a/data/js/jquery/other/jquery.tmpl.js b/data/js/jquery/other/jquery.tmpl.js
index 213d136..cc5ee0c 100644
--- a/data/js/jquery/other/jquery.tmpl.js
+++ b/data/js/jquery/other/jquery.tmpl.js
@@ -323,7 +330,9 @@
// Convert the template into pure JavaScript
jQuery.trim(markup)
.replace( /([\\'])/g, "\\$1" )
- .replace( /[\r\t\n]/g, " " )
+ .replace( /\n/g, "\\n")
+ .replace( /\r/g, "\\r")
+ .replace( /\t/g, "\\t")
.replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )
.replace( /\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
function( all, slash, type, fnargs, target, parens, args ) {
from jquery-tmpl.
Thanks for taking the time to submit this issue. Just wanted to let you know this plugin is no longer being actively developed or maintained by the jQuery team. See README for more info.
from jquery-tmpl.
You should fix this issue
from jquery-tmpl.
Related Issues (20)
- tmpl inside of each HOT 2
- support jQuery 1.7+ ? HOT 1
- README is out of date HOT 5
- Add API Documentation to README HOT 5
- {{switch}} statement is needed for jquery-tmpl HOT 1
- JsView append data with the event attach to it. HOT 2
- http://api.jquery.com/category/plugins/templates/ 这个地址打开就说"Not Found",地址失效啦? HOT 1
- can use jquery-tmpl in Dust ?
- [enhancement] Add missing bower.json.
- You don't seem to be active here. HOT 1
- varaible naming with @ HOT 1
- Can I use jquery template without html file and compile them by some tools like node js HOT 1
- How to process data with PHP in the template HOT 1
- getting mails for every person update stop to receiving mails HOT 1
- How can I get substring from parsed html in jquery.tmpl HOT 2
- Nested tmpls HOT 2
- $obj.tmpl().html() can not return whole html , i need a method to return this dom's whoe html ? HOT 3
- Index of first array element HOT 1
- Unnecessary http request happening when applying template inside ajax success request
- RangeError: Maximum call stack size exceeded
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 jquery-tmpl.