How to render standalone Symfony Form without Twig? - symfony-forms

I have Symfony\Component\Form\FormView object. How do I render it without Twig and framework?
Specifically I want to use Symfony Form in Concrete5 custom block type.

Related

How can I pass children to a component in a slim template using react_rails

I'm using react_rails to render react components inside of a slim template in a Ruby on Rails application. Is there a way to pass children to a React component, where the children are rendered server-side in slim?
Here is what I would ideally like to have:
<MyComponent>
<p>my custom content</p>
</MyComponent>
Where the content comes from the template itself, something like this:
= react_component 'MyComponent' do
p my custom content
Is this possible? If so what's the best way to pass children to a react_component?
On page load, the react_ujs driver will scan the page and mount components using data-react-class and data-react-props.
The view helper's signature is:
react_component(component_class_name, props={}, html_options={})

Rails: Create a form wrapper using partials

I have a form_for in all of my views. Now I need to insert a hidden html input element in all of these views.
Is there anyway I could specify a wrapper over form using partials where I take all the form parameters , do my own logic of inserting the hidden input element and render the rest of the block given by the views? How can I do this?
Yes, I think you can write your own logic in views through helpers, Helpers provide you more flexibility, consistency, and also provide functionality to keep your code DRY(the basic feature of Rails). you can write your helper methods in app/helpers/application_helper.rb.
You can have a look on this guide:
http://guides.rubyonrails.org/form_helpers.html
Hope it will help you in what you were looking for.Thanks

how do i dynamically change my format rendering engine in rails?

My default templating engine is haml, but I would to sometimes change it to erb if i specify a specific parameter?
For example, I am pasting in some html code and would just like to test the code without HAML complaining about its format.
Any idea how to do this?
do something like:
if params[:render_erb]
render 'file.html.erb'
else
render 'file.html.haml'
end
and call the action with ?render_erb=true
or
render "file.html.#{params[:render]}" ir params[:render]
and call it ?render=haml or ?render=erb (or nothing and it will use the default
at the end of the controller's action that you are using
Am I wrong that you simply need to save file as your_file.html.erb instead of your_file.html.haml?
You can use different templates in the same application, and you can use different template engines for views, partials, and layouts, but as far as I know you can't duck in and out of multiple template engines within the same template file.
If you just want to drop some code in using a different template language, then I'd put it in a separate partial. That certainly seems easiest in this particular case.

How to include contents of plain HTML or classic ASP file in an ASP.net MVC 3 view?

I'm working on an ASP.net MVC 3 application. I have an external classic ASP file that renders a fragment of a page.
I understand that in ASP.net MVC 3, I can define a partial view to contain a fragment of HTML that I want to reuse on multiple pages.
The basic idea that I have is that I would like to use an external classic ASP file to render a fragment of HTML in my ASP.net MVC 3 application.
I would like to use it with something like Html.Partial, but that won't work because a classic ASP file is obviously not an MVC partial view.
Another way of doing this would be to add the content of the file to the page with AJAX, but I don't want to add the overhead of another AJAX call to my page. What might be the solution I'm looking for?
Plain HTML: Just read it from disk and output it with #Html.Raw().
Asp or other dynamically created content: You may use HttpWebRequest to get the html markup, and then insert into you own view. You may want to cache the response.
For convenience, you may create extension methods for both methods.
Create a Controller Action that makes the external call and returns the content:
Html.RenderAction("GetContent","ExternalASP"); //GetContent- Action, ExternalASP- Controller

HTMl Helpers in MVC: How do I render html tags with helper such as ActionLink?

When using ActionLink to render data from database which has HTML tags
(ie <p>)
incorporated in it, ActionLink escapes the tags. What is the best way to handle this?
In valid (X)HTML, paragraph tags are disallowed inside of anchor tags, so I wouldn't expect the framework to allow it.
I don't know that you can turn off the XSS protection in the helper methods, but you can always build your own helper methods. Just make an extension method that hangs off the Html class.
If you just want to render some HTML from the database, you can use <%= ViewData["MyContent"] %> if you're controller loads the data into the MyContent view data. Just know that you have to clean this HTML yourself.

Resources