# CASE: make your code readable with stripnewlines and newline

**URL:** <https://community.silverfin.com/t/case-make-your-code-readable-with-stripnewlines-and-newline/366>\
**Category:** Cases\
**Tags:** case, stripnewlines\
**Created:** [August 3, 2017, 1:17pm UTC](https://community.silverfin.com/t/case-make-your-code-readable-with-stripnewlines-and-newline/366 "2017-08-03T13:17:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamVanEenoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/samvaneenoo/32/134_2.png) [@SamVanEenoo](https://community.silverfin.com/u/SamVanEenoo)\
**Post date:** [August 3, 2017, 1:17pm UTC](https://community.silverfin.com/t/case-make-your-code-readable-with-stripnewlines-and-newline/366/1 "2017-08-03T13:17:21Z")

</div>

**1. Stripnewlines tag**  
**2. Stripnewlines and tables**  
**3. Newline tag**

Making sure your code is well structured is very important in every programming language. It builds logic into your code and you will profit from it in many ways:

- It will help you to understand your code better
- You won’t make errors as fast
- When you do make an error, you’ll find if faster
- It helps other people to understand your code faster  
  
  
**1. Stripnewlines tag**

Before we go into the newline tag, we’ll have a look at the stripnewlines tag. This tag makes sure that when using indentation, the visualisation of your code is still as you expect. A simple example to show you how this works.

We used following code with and without the stripnewlines tag:

```
{% stripnewlines %}
{% assign me = true%}
    
{% if me == true%}
  My name is
{% else %}
  Your name is
{% endif %}

Sam
{% endstripnewlines %}

```

_Fig 1.1. Simple code_  
  
  
 ![04](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/b84ed71b3c33501e3adfbb84f70b7600c6514af0.png)  
_Fig 1.2 Result without stripnewlines_  
  
  
 ![16](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/527e5a910256c591bb9984e522149e14e2512e9b.png)  
_Fig 1.3 Result with stripnewlines_  
  
  
This is a simple example of how the stripnewlines tag works.  
  
  
**2. Stripnewlines tag and tables**

This tag however has one disadvantage. You can’t use this tag on an entire table. Another example will show us why:

![43](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/c64da238db57783e39a2d94b5a016516bb7fddf9.png)  
_Fig 2.1 Simple table code_  
  
  
 ![01](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/a65de34c80671b6f8ebdf5ef94510d97601ecb02.png)  
_Fig 2.2 Above code without stripnewlines tag_  
  
  
 ![42](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/c0aa5d9cf3eaef69e67f0afb54019377db56102f.png)  
_Fig 2.3 Above code with stripnewlines tag_  
  
  
As you can see, the table is broken by the stripnewlines tag, luckily there’s a solution!  
  
  
**3. Newline tag**

Let’s start with another example. Look at the following code:

 ![30](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/a035c0a01c071b64c92012afbdf00b2aa9ea6228.png)  
_Fig 3.1 Simple hard to read code_  
  
  
This code shows the price of a product with and without VAT. The tax rate depends on the kind of product. Although the example above is still relatively simple, it’s hard to read. Luckily we can use a combination of the stripnewlines and the newline tag to give structure to our code.

![17](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/62bcdce09f3fb4f21a403224189a134a63dd6582.png)  
_Fig 3.2 Simple easy to read code_  
  
  
The code above is much easier to read. Just use the stripnewlines tag around the entire table and the newline tag everytime you want to start a new row. This will definetly be helpful when facing complex codes.

 ![46](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/9ba438d8b15914b67ca15818ddf58e2427c83b5a.png)  
_Fig 3.3 Result_  
  
  
We hope this will help you in the future.  
If you have any questions, don’t hesitate to ask them.

Kind regards  
The Silverfin Team
