2018-08-31

드럼


드럼 -1


시나트라3

: Layouts 

< web organizing techi > 
  • [q] Another very powerful way for organizing our website code is by using layouts. 
    • it's not uncommon when we're bui..
** start of layout 
<%= yield %>
** end of layout


  • [q] So, yield is essentially saying the template code drops in right ..yield that happens automatically before rendering that template. 
  • code example : ~~.erb
    <html> 
        <head> 
        </head>
        <body>
            <div id="navigation">
                <%= erb :navigation %>
            </div>
            <div id="main-content">        
                <%= yield %>
            </div>
        </body>
    </html> 

  •     
    • You can see I have those ERB tags with yield inside, that's where the template part would be dropped in.
    • So, it would be just a small bit of code that gets dropped in to this larger layout. 
    • So, my template file no longer has to have all the beginning and ending HTML, that's going to be in my layout. 
  • Point : Layouts : Render template inside common page elements. 

시나트라 2

  • Partial 
<%= erb "_navigation".to_sym %> 
  • <%= : evaluate and put out the result into stringn. 


  • <% : just 
  • evaluate them.
  • file directory only take symbol.
  • [q] We just come into our template, you call erb, and as long as you pass in a symbol, that locates the file, then it'll render it for you. 
  • reusable piece ( like function ) 

시나트라

#여기! 를 찾아보시오

라이브러리를 이해 해야되는데 이 작은 두뇌로는... 
지금 당장은 자야겠습니다...
sinatra does two things. 
it routes browser requests to code that can handle those requests and then from there it will render templates back to the browser as a response. 


.. We start at the browser, it sends a request to the web server, which sends a request through the public folder to the Rails framework and from there we have code that routes our 

1.4.8 


# route

.. The first step is you must require (load the feature(!)) the Sinatra gem(external library) . After tha,t you need to make sure that you have a root route definition. 

- load the sinatra gemm, have a root route def. 

(?) Thin web server : 



Routes are going to be matched in order from the top of the file. That means that Sinatra's going to start at the top of our routes and go down until it finds one that mathces. If there happens to be another match further down, It will never get there. 




#Route HTTP methods
request's'
  • post
  • put
  • patch
  • delete.. 

-- 

get, post example

different name 


from the doc 

.get(path, opts = {}, &block) ⇒ Object


path -> '/'  '/forum' .. 

  1. get -request , make link 






[q] There's no other way to get that post request except to click submit.

이해가 안가는 부분이 있는데. 무조건 form 형태의 - 태그는 post형태의 method request를 보내는 건가? 



< Route Patterns > (yeh!!!) 


## ( check charater : regular expression ) 

  • example : 


The most important is to notice that it's not a string. 


error
arjuna@ARJUNA-2:~/88Driver/#Work/MyCode/Ruby/Sinatra$ ruby 'test_1.rb'
/usr/local/lib/ruby/gems/2.3.0/gems/mustermann-1.0.0/lib/mustermann/regular.rb:40:in `check_anchors': regular expression should not contain \A: "\\A\\/company\\/[A-Za-z\\-]+\\Z" (Mustermann::CompileError)


#여기!





#mini note : 
  • questions
    • [q]html, tag, single or double quotation makrk
      • I know they both work and are supported by all modern browsers but is there a real difference where one is actually better than the other in different situations?
      • Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa
        • ' "" ' 
        • " '' " 
        • delimited ( determined de : down ) 
    • [q] html input's attribute -> value 
      • value
      • The initial value of the control. This attribute is optional except when the value of the type attribute is radio or checkbox.
    • [r] regex test 해주는 우오! : http://regexr.com/