Line breaks not working properly with Laravel Text Emails / Testing in Mailhog - laravel

If I understood correctly, in laravel text emails it is not necessary to add "\n" for example,
but it seems that, some times the "enters" ( new lines ) I add work properly, sometimes not.
I've been trying to figure it out anc it is a mystery, seen some people with the same issue but haven't found a solution yet.
Some examples/tests below:
Edit:
HTML is not being used! I'm calling ->text( and not->view(:

Added 2 spaces BEFORE the line break, Issue solved.
Make sure your IDE is not trimming spaces at the end!!
Which was my case with VSCode ( not sure if some plugin or native will figure out soon )

You are using Blade Template from Laravel, and Blade uses html tags.
In your case, since you are using HTML anyway, why not use breaklines, paragraphs, divs or anything that is a block element so that you can efficiently add a newline.
<p>
<br>
<div>
Or much better approach is to use Markdown template for Emails as documented from official Laravel page, Markdown mailables

Related

Laravel Blade Php View: Is there a way to ignore any space before "#foreach #if" . etc?

I am new to Laravel.
It seems like in default setting, the following code
#foreach($foo as $bar)
<div>
would generate 8 white spaces before the div in actual final html code.
I want to know is there a way to ignore the 4 spaces before the #foreach and only use the 4 spaces before the div?
A related but different question: Laravel Blade comment before "#if"
In this question the author seems to do what I am doing right now, which is essentially leave no space before the #foreach but the drawback is the source code looks ugly. Ideally there should be a way to make the code look nice while also not affecting the final output.

Vue.js Component Template Type

At my company, for templates for Vue.js, we write components in separate Blade files. The problem I have is that HTML code is not highlighted in those files. Whole HTML code is written inside script tags which has the syntax:
<script type="x/templates" id="nameOfComponent">.
By deleting the type attribute, highlighting starts working correctly. I have searched a little bit and found that there are different types, but I have never seen one like the one above (the closest one I saw is text/x-template and highlighting works with it). Now, as I am not allowed to change these kinds of things, I have a couple of questions (also, I have to mention I'm new to JavaScript and PHP):
If this is not predefined type, are user-defined types supported?
If so, is there any extension for VS code which would highlight HTML part of the code?
If user-defined types are not the right solution, which one would be the best solution for me?
try:
https://github.com/vuejs/vetur
Pretty sure it should support vue template syntax highlighting.

Django mardownx not displaying header and blockquotes

Simple blog in Django (1.11.7 - Python3) in which I have impemented the Markdownx plugin. The plugin works for most of the markdown in preview in my 'edit_article' page, and in the normal view where users can read an article. BUT some of the markup isn't working in either:
Not working:
blockquotes using >
headers using one or more # or _
double-space and carriage return doesn't add a line-break
Links, images, numbered lists, emphasis and bold etc all work.
I posted my markdown in here, but of course it all worked here...
Don't really have any code to post, because most things work, so I'm guessing there isn't any problem with my model/view etc.
Anyone experienced this?
# So, let's try a header
doesn't work, neither does
> this type of blockquote
but they shoud produce
So, lets try a header
and
this type of blockquote
So I found the answer to this myself. I am using a CSS framework that resets the styling on the 'broken' markup tags. Until I add back the framework's CSS classes to the H1-H6 tags for example, the reset makes all headers appear as plain text.
So I have to add some custom CSS to the css framework's styling for those tags that are being overridden, or use html in the textarea in the form which should also work.

How can I stop Joomla from stripping HTML code from the Contact info?

I've only spent maybe 30 mins searching online for this, and couldn't come up with a decent answer.
But anyway, in Joomla there are normal input fields for the Contacts component, but there's a textarea for the Address.
This would make me assume you can enter multiple lines of address in there, and it would be displayed as separate lines... but it doesn't. Even if I enter line breaks, the output is rendered on one line.
So I try to enter <br> to separate, and upon saving, Joomla strips these tags out.
In the template, the output is being written simply by echoing $this->contact->address
Is there anyway, to explode this input and replace linebreaks with <br> marks?
UPDATE:
For now as a temporary measure I'm able to add HTML code into the database values, which saves and outputs on the front end.
On a separate note, I'm now looking to remove the Subject line from the contact form, without hacking the code. and by using overrides as much as possible. Can anyone help?
Have you tried the Sourcerer extension?
Your question is pretty old, but did you get a solution to this Lee?
To create line-breaks in Joomla, titles, text areas etc. Easiest way to do this is to use the ReReplace extension from NoNumber: http://extensions.joomla.org/extensions/edition/replace/4336
I personally use this to add line break in e.x. menu-item titles, where < br / > aren't allowed and get stripped.
With ReReplacer, you can create a custom tag e.x. {br} and then have ReReplacer replace {br} with < br / >.
So everytime you need to add a line break anywhere in Joomla, where html codes usually get stripped, you can just add {br} to have it add a new line.
Very old question but I've fallen into the same issue and tried to find a more user friendly solution.
You can enter multiple lines in the address textarea, and they are correctly outputted to the HTML page source. But as you know, newlines in HTML are not rendered, they have to be transformed to <br>.
For this PHP has a nice function, nl2br, that inserts a <br> each time it encounters a newline in a string.
So in html\com_contact\contact\default_address.php of your template, replace:
echo $this->contact->address;
with
echo nl2br($this->contact->address);
This would nicely do the job, and allow the user to naturally insert any newline in the contact address textarea that will be correctly rendered with the appropriate <br>; I believe this is quite more user friendly solution than your previous one of the user having to insert -br- tags in the address field.

CKEditor with HTML content stores, displays but cannot display for edit

I have used CKEditor for a few years without really understanding it. I now want to use it to display text which will include HTML, CSS, JavaScript and PHP example code. None of that needs to execute it is just to show the code to others.
Currently I used the textarea replace method to edit content and I need to carry on that way. When I add the content first time it is sanitised (mysqli_real_escape_string) and stored in a MySQL database correctly. It also then displays correctly with the CKEditor markup working as markup and the HTML/PHP showing as a code example. However, when I edit the content a second time the HTML examples become "real" HTML and are no longer visible as examples.
For example this:
<?php echo "hello"; ?>
<p>Hello</p>
is correctly (?) stored as:
<p><?php echo "me"; ?></p>
<p><p>Hello</p></p>
and displays on the page as shown in the first code snippet (which is what I want). When I then hit edit again the code examples vanish into the background as real HTML (part of the page). If I put the code examples in as code snippets (which I would rather not have to do because of the intended users) the result in the editor (second edit) looks like this:
<!--?php echo "me"; ?-->
Hello
I am sure i am missing a basic understanding of what is going on behind the scenes but can anyone explain how to allow users to type in text which includes HTML, CSS, JavaScript, PHP and MySQL code examples which must then appear as examples and not markup (and be editable as examples).
I have played with config.entities and config.protectedSource after some research but they do not seem to be relevant (or to work). Weirdly a couple of times it seemed to work fine and I thought I had cracked it but then stopped with no further changes to the config. That means I now have less idea what I am doing than when I started!
You don't mention which version you are using, but if it's relatively new (4.4+) you can use the Code Snippets plugin that was designed exactly for this. See the demo at http://ckeditor.com/demo#widgets. It might help with the encoding issues too. There's docs on it too.
Th help with the current encoding issue, it would help a LOT if you showed us how you output the data and load it into CKEditor. For example "When I then hit edit again" doesn't really describe anything without context. For example, do you use setData() with AJAX? Do you use an inline editor? Code examples would be the best.

Resources