Jump to content
php.lv forumi
  • 0

JS html templeiti


hjkl
 Share

Question

Kāda ir jūsu pieredze ar lapām kur prasās ar JS palīdzību ģenerēt lielus HTML gabalus? Nevis pieprasīt visu laiku ar ajax no servera, bet nemitīgi atjaunināt balstoties uz kaut kādiem mainīgajiem? Esmu lasījis par vairākiem JS template dziņiem, bet izmēģinājis nevienu neesmu.

Link to comment
Share on other sites

  • Answers 82
  • Created
  • Last Reply

Top Posters For This Question

Recommended Posts

  • 0

Vispār JSX atļaut lietot lielus ternary operatorus. It kā pilda handlebars if-else funkciju. Varbūt nav tik smuki, bet darbojas tak:

{ this.state.error ? (
    <h1>
        Nepareizi dati!
        <p>info ko redz tikai tad, ja dati ir nepareizi</p>
    </h1>
) : (
    <h1>
        Viss bumbā
        <p>Info ko redz tikai tad, ja dati ir pareizi</p>
    </h1>
)}

Link to comment
Share on other sites

  • 0

Neko nevajag atļaut. Tas, ka tas ir logic-less, ir tas pluss.

 

Es lietoju tīru JavaScript (tobiš CoffeeScript, bet that's not the point). Viss ko JSX dara ir paņem <Foo x=42 /> un uztaisa par Foo({x: 42}) — tā es arī rakstu.

 

https://gist.github.com/140755c4062f5fac6d00

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share


×
×
  • Create New...