Reputation: 5461
I am using liquid to format some data into a document. I am fetching the value of a variable and printing it and just after that i want to put a border line. The problem is that if it is of one line then there is no problem but if the {{ business.name }} extends to several lines, then there is problem in printing of border line, since border line is printed just after first line.
How can we determine that the value of the variable extends to several lines or one line, so that i could place the border line according to that.
<div> {{ business.name }} </div>
<div class="border-top"> </div>
Upvotes: 1
Views: 108
Reputation: 514
The way to calculate the number of lines is using jQuery, which is counting the height of the <div>
containing the business.name.
However, instead of using the jQuery, the following are other alternatives:
<div class="border-bottom"> {{ business.name }} </div>
Another alternative is:
<div>
{{ business.name }}
<div class="border-class-here"></div>
</div>
Hope this helps
Upvotes: 5
Reputation: 4655
Using PHP or JavaScript you can regex search for newlines (<br/>
, <br>
). Count them, and you know how many lines you have.
Upvotes: -2