Search code examples
cssruby-on-railsrubystringhaml

How to add hyphenations for a field in markup?


There is a field(auth_public_key) whose value may go beyond the markup:

  - if @connection.auth_public_key.present?
    %el-row.m-b-10
      %el-col.p-t-15.p-b-15.p-l-20.p-r-20{":span": "24"}
        %span= @connection.auth_public_key

Q: how can I add hyphens depending on the length? smth like overflow-wrap: break-word;

What is happening now:

Field value: aaaaaaaaa
I expect: aaa\naaa\naaa

Solution

  • Solved with next solution:

    Change code in my .haml file

      %el-col.p-t-15.p-b-15.p-l-20.p-r-20
        %code= @connection.auth_public_key
    

    After this added in common.scss file

    // Code 
    code {
      word-break: break-word;
    }