1. Блок-обозначения: новые строки становятся пробелами и дополнительными символами новой строки после удаления блока
---
# Note: it has 1 new line after the string
content:
Arbitrary free text
over multiple lines stopping
after indentation changes...
...
Эквивалентный JSON
{
"content": "Arbitrary free text over multiple lines stopping after indentation changes..."
}
2. Литературный блок Скаляр: скалярный блок | будут включать в себя новые строки и любые конечные пробелы. но удаляет дополнительные
строки новой строки после блока.
---
# After string we have 2 spaces and 2 new lines
content1: |
Arbitrary free text
over "multiple lines" stopping
after indentation changes...
...
Эквивалентный JSON
{
"content1": "Arbitrary free text\nover \"multiple lines\" stopping\nafter indentation changes... \n"
}
3. + с литеральным блочным скаляром: сохранить дополнительные строки после блока
---
# After string we have 2 new lines
plain: |+
This unquoted scalar
spans many lines.
...
Эквивалентный JSON
{
"plain": "This unquoted scalar\nspans many lines.\n\n\n"
}
4. - индикатор с Literal Block Scalar: - означает, что строка новой строки в конце строки удалена.
---
# After string we have 2 new lines
plain: |-
This unquoted scalar
spans many lines.
...
Эквивалентный JSON
{
"plain": "This unquoted scalar\nspans many lines."
}
5.
---
folded_newlines: >
this is really a
single line of text
despite appearances
...
Эквивалентный JSON
{
"fold_newlines": "this is really a single line of text despite appearances\n"
}
:
будет складывать новые строки в пробелы, но удаляет дополнительные строки новой строки. более подробно вы можете посетить мой блог
Если вы используете эту функцию для генерации версии HTML5 datepicker для браузеров, формат даты должен быть yyyy-MM-dd
(формат ISO). Используя TextBoxFor()
, он должен быть
@Html.TextBoxFor(m => m.InitialDate, "{0:yyyy-MM-dd}", new { @class = "form-control", type = "date" })
. В качестве альтернативы добавьте следующие атрибуты к свойству
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public Nullable<System.DateTime> InitialDate { get; set; }
и в представлении используйте
@Html.EditorFor(m => m.InitialDate)
Обратите внимание, что это добавляет атрибут type="date"